Skip to content

Commit 2ca1eeb

Browse files
Update Soroban protocol version to match testnet (hyperledger-solang#1821)
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu> Co-authored-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu> Co-authored-by: salaheldinsoliman <49910731+salaheldinsoliman@users.noreply.github.com>
1 parent a3b6d3c commit 2ca1eeb

13 files changed

Lines changed: 167 additions & 178 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,12 @@ jobs:
317317
run: |
318318
chmod 755 ./bin/solang
319319
echo "$(pwd)/bin" >> $GITHUB_PATH
320-
320+
- name: Install system dependencies for stellar-cli
321+
run: apt-get update && apt-get install -y libdbus-1-dev pkg-config
321322
- name: Install Soroban
322-
run: cargo install --locked stellar-cli --version 22.0.0
323+
run: cargo install --locked stellar-cli --version 23.0.0
324+
- name: Add wasm32v1-none target
325+
run: rustup target add wasm32v1-none
323326
- name: Add cargo install location to PATH
324327
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
325328
- run: npm install
@@ -328,7 +331,7 @@ jobs:
328331
run: npm run build
329332
working-directory: ./integration/soroban
330333
- name: Build rust contracts
331-
run: soroban contract build --profile release-with-logs
334+
run: stellar contract build --profile release-with-logs
332335
working-directory: ./integration/soroban/rust/contracts
333336
- name: Setup Soroban enivronment
334337
run: npm run setup

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ solang-forge-fmt = { version = "0.2.0", optional = true }
7171
# We don't use ethers-core directly, but need the correct version for the
7272
# build to work.
7373
ethers-core = { version = "2.0.10", optional = true }
74-
soroban-sdk = { version = "22.0.7", features = ["testutils"], optional = true }
74+
soroban-sdk = { version = "23.0.0-rc.2.2", features = ["testutils"], optional = true }
7575

7676
[dev-dependencies]
7777
num-derive = "0.4"

integration/soroban/auth_framework.spec.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { readFileSync } from 'fs';
33
import { expect } from 'chai';
44
import path from 'path';
55
import { fileURLToPath } from 'url';
6-
import { call_contract_function, extractLogEvent } from './test_helpers.js';
7-
import { assert } from 'console';
6+
import { call_contract_function, toSafeJson } from './test_helpers.js';
7+
import { Server } from '@stellar/stellar-sdk/rpc';
88

99
const __filename = fileURLToPath(import.meta.url);
1010
const dirname = path.dirname(__filename);
11-
const server = new StellarSdk.SorobanRpc.Server("https://soroban-testnet.stellar.org:443");
11+
const server = new Server("https://soroban-testnet.stellar.org");
1212

1313
function readContractAddress(filename) {
14-
return readFileSync(path.join(dirname, '.soroban', 'contract-ids', filename), 'utf8').trim();
14+
return readFileSync(path.join(dirname, '.stellar', 'contract-ids', filename), 'utf8').trim();
1515
}
1616

1717
describe('Auth Framework', () => {
@@ -28,34 +28,28 @@ describe('Auth Framework', () => {
2828
});
2929

3030
it('calls a', async () => {
31-
32-
3331
let values = [
34-
b.address().toScVal(),
35-
c.address().toScVal()
32+
b.address().toScVal(),
33+
c.address().toScVal()
3634
];
37-
38-
3935
let res = await call_contract_function("call_b", server, keypair, a, ...values);
4036

41-
42-
expect(res.returnValue().value().toString()).to.equal("22");
43-
37+
expect(res.status, `Call to 'a' contract failed: ${toSafeJson(res)}`).to.equal("SUCCESS");
38+
expect(res.returnValue, `Unexpected return value for 'a': ${toSafeJson(res)}`).to.equal(22n);
4439
});
4540

46-
it ('call falis with invalid `a` contract', async () => {
47-
48-
41+
it('call fails with invalid `a` contract', async () => {
4942
let values = [
50-
b.address().toScVal(),
51-
c.address().toScVal()
43+
b.address().toScVal(),
44+
c.address().toScVal()
5245
];
53-
5446
let res = await call_contract_function("call_b", server, keypair, a_invalid, ...values);
5547

56-
assert(res.toString().includes("recording authorization only] encountered authorization not tied to the root contract invocation for an address. Use `require_auth()` in the top invocation or enable non-root authorization."));
57-
48+
expect(res.status).to.not.equal("SUCCESS");
49+
expect(
50+
res.error || toSafeJson(res),
51+
'Missing expected Soroban auth error message'
52+
).to.include("recording authorization only] encountered authorization not tied to the root contract invocation for an address. Use `require_auth()` in the top invocation or enable non-root authorization.");
5853
});
5954

60-
6155
});

integration/soroban/counter.spec.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,45 @@ import { readFileSync } from 'fs';
33
import { expect } from 'chai';
44
import path from 'path';
55
import { fileURLToPath } from 'url';
6-
import { call_contract_function } from './test_helpers.js';
6+
import { call_contract_function, toSafeJson } from './test_helpers.js';
7+
import { Server } from '@stellar/stellar-sdk/rpc';
78

89
const __filename = fileURLToPath(import.meta.url);
910
const dirname = path.dirname(__filename);
1011

1112
describe('Counter', () => {
12-
let keypair;
13-
const server = new StellarSdk.SorobanRpc.Server(
14-
"https://soroban-testnet.stellar.org:443",
15-
);
13+
let keypair, contract;
14+
const server = new Server("https://soroban-testnet.stellar.org");
1615

17-
let contractAddr;
18-
let contract;
1916
before(async () => {
20-
2117
console.log('Setting up counter contract tests...');
2218

2319
// read secret from file
2420
const secret = readFileSync('alice.txt', 'utf8').trim();
2521
keypair = StellarSdk.Keypair.fromSecret(secret);
2622

27-
let contractIdFile = path.join(dirname, '.soroban', 'contract-ids', 'counter.txt');
23+
let contractIdFile = path.join(dirname, '.stellar', 'contract-ids', 'counter.txt');
2824
// read contract address from file
29-
contractAddr = readFileSync(contractIdFile, 'utf8').trim().toString();
30-
25+
const contractAddr = readFileSync(contractIdFile, 'utf8').trim();
3126
// load contract
3227
contract = new StellarSdk.Contract(contractAddr);
3328
});
3429

3530
it('get correct initial counter', async () => {
36-
// get the count
37-
let count = await call_contract_function("count", server, keypair, contract);
38-
console.log(count.returnValue().value());
39-
expect(count.returnValue().value().toString()).eq("10");
31+
let res = await call_contract_function("count", server, keypair, contract);
32+
33+
expect(res.status, `Counter 'count' call failed: ${toSafeJson(res)}`).to.equal("SUCCESS");
34+
expect(res.returnValue, `Unexpected counter value: ${toSafeJson(res)}`).to.equal(10n);
4035
});
4136

4237
it('increment counter', async () => {
4338
// increment the counter
44-
await call_contract_function("increment", server, keypair, contract);
39+
let incRes = await call_contract_function("increment", server, keypair, contract);
40+
expect(incRes.status, `Counter 'increment' call failed: ${toSafeJson(incRes)}`).to.equal("SUCCESS");
4541

46-
// get the count
47-
let count = await call_contract_function("count", server, keypair, contract);
48-
expect(count.returnValue().value().toString()).eq("11");
42+
// get the count again
43+
let res = await call_contract_function("count", server, keypair, contract);
44+
expect(res.status, `Counter 'count' after increment failed: ${toSafeJson(res)}`).to.equal("SUCCESS");
45+
expect(res.returnValue, `Unexpected counter value after increment: ${toSafeJson(res)}`).to.equal(11n);
4946
});
5047
});
51-
52-

integration/soroban/cross_contract.spec.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ import { readFileSync } from 'fs';
33
import { expect } from 'chai';
44
import path from 'path';
55
import { fileURLToPath } from 'url';
6-
import { call_contract_function, extractLogEvent } from './test_helpers.js';
6+
import {
7+
call_contract_function,
8+
extractLogMessagesFromDiagnosticEvents,
9+
toSafeJson,
10+
} from './test_helpers.js';
11+
import { Server } from '@stellar/stellar-sdk/rpc';
712

813
const __filename = fileURLToPath(import.meta.url);
914
const dirname = path.dirname(__filename);
10-
const server = new StellarSdk.SorobanRpc.Server("https://soroban-testnet.stellar.org:443");
15+
const server = new Server("https://soroban-testnet.stellar.org");
1116

1217
function readContractAddress(filename) {
13-
return readFileSync(path.join(dirname, '.soroban', 'contract-ids', filename), 'utf8').trim();
18+
return readFileSync(path.join(dirname, '.stellar', 'contract-ids', filename), 'utf8').trim();
1419
}
1520

1621
describe('Cross Contract Calls', () => {
@@ -34,13 +39,13 @@ describe('Cross Contract Calls', () => {
3439
].map(StellarSdk.xdr.ScVal.scvU64);
3540

3641
let res = await call_contract_function("add", server, keypair, caller, addr, ...values);
37-
let returnValue = res.returnValue().value().toString();
3842

39-
console.log(returnValue);
40-
expect(returnValue).to.equal("3");
43+
expect(res.status, `Rust contract tx failed: ${toSafeJson(res)}`).to.equal("SUCCESS");
44+
// Return value is already decoded (should be 3n for u64 add)
45+
expect(res.returnValue, `Unexpected returnValue for Rust contract: ${toSafeJson(res)}`).to.equal(3n);
4146

42-
let logMessages = extractLogEvent(res.diagnosticEvents()).logMessages;
43-
console.log(logMessages);
47+
const logMessages = extractLogMessagesFromDiagnosticEvents(res.raw);
48+
expect(logMessages.length > 0, "No logMessages found in Rust contract response").to.be.true;
4449
expect(logMessages[0]).to.contain('Soroban SDK add function called!');
4550
});
4651

@@ -53,13 +58,12 @@ describe('Cross Contract Calls', () => {
5358
].map(StellarSdk.xdr.ScVal.scvU64);
5459

5560
let res = await call_contract_function("add", server, keypair, caller, addr, ...values);
56-
let returnValue = res.returnValue().value().toString();
5761

58-
console.log(returnValue);
59-
expect(returnValue).to.equal("3");
62+
expect(res.status, `Solidity contract tx failed: ${toSafeJson(res)}`).to.equal("SUCCESS");
63+
expect(res.returnValue, `Unexpected returnValue for Solidity contract: ${toSafeJson(res)}`).to.equal(3n);
6064

61-
let logMessages = extractLogEvent(res.diagnosticEvents()).logMessages;
62-
console.log(logMessages);
65+
const logMessages = extractLogMessagesFromDiagnosticEvents(res.raw);
66+
expect(logMessages.length > 0, "No logMessages found in Solidity contract response").to.be.true;
6367
expect(logMessages[0]).to.contain('add called in Solidity');
6468
});
6569
});

integration/soroban/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"dependencies": {
4-
"@stellar/stellar-sdk": "^12.0.1",
4+
"@stellar/stellar-sdk": "14.0.0-rc.2",
55
"chai": "^5.1.1",
66
"dotenv": "^16.4.5",
77
"mocha": "^10.4.0"

integration/soroban/runtime_error.spec.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,40 @@ import { readFileSync } from 'fs';
33
import { expect } from 'chai';
44
import path from 'path';
55
import { fileURLToPath } from 'url';
6-
import { call_contract_function } from './test_helpers.js';
6+
import { call_contract_function, toSafeJson } from './test_helpers.js';
7+
import { Server } from '@stellar/stellar-sdk/rpc';
78

89
const __filename = fileURLToPath(import.meta.url);
910
const dirname = path.dirname(__filename);
1011

1112
describe('Runtime Error', () => {
12-
let keypair;
13-
const server = new StellarSdk.SorobanRpc.Server(
14-
"https://soroban-testnet.stellar.org:443",
15-
);
13+
let keypair, contract;
14+
const server = new Server("https://soroban-testnet.stellar.org");
1615

17-
let contractAddr;
18-
let contract;
1916
before(async () => {
20-
2117
console.log('Setting up runtime_error.sol contract tests...');
2218

2319
// read secret from file
2420
const secret = readFileSync('alice.txt', 'utf8').trim();
2521
keypair = StellarSdk.Keypair.fromSecret(secret);
2622

27-
let contractIdFile = path.join(dirname, '.soroban', 'contract-ids', 'Error.txt');
28-
// read contract address from file
29-
contractAddr = readFileSync(contractIdFile, 'utf8').trim().toString();
23+
const contractIdFile = path.join(dirname, '.stellar', 'contract-ids', 'Error.txt');
24+
const contractAddr = readFileSync(contractIdFile, 'utf8').trim();
3025

31-
// load contract
3226
contract = new StellarSdk.Contract(contractAddr);
3327

34-
// call decrement once. The second call however will result in a runtime error
28+
// call decrement once (to reach error state on the next call)
3529
await call_contract_function("decrement", server, keypair, contract);
3630
});
3731

3832
it('prints error', async () => {
33+
// decrement the counter again, expecting a runtime error
34+
const res = await call_contract_function("decrement", server, keypair, contract);
3935

40-
// decrement the counter again, resulting in a runtime error
41-
let res = await call_contract_function("decrement", server, keypair, contract);
42-
43-
expect(res).to.contain('runtime_error: math overflow in runtime_error.sol:6:9-19');
36+
expect(res.status).to.not.equal("SUCCESS");
37+
// The error message may be in res.error or a safe string version
38+
const errorString = res.error || toSafeJson(res);
39+
expect(errorString).to.contain('runtime_error: math overflow in runtime_error.sol:6:9-19');
4440
});
4541

4642
});
47-
48-

integration/soroban/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = [
55
]
66

77
[workspace.dependencies]
8-
soroban-sdk = "22"
8+
soroban-sdk = { version = "23.0.0-rc.2.3" }
99

1010
[profile.release]
1111
opt-level = "z"

integration/soroban/setup.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function exe(command) {
2121
}
2222

2323
function generate_alice() {
24-
exe(`${soroban} keys generate alice --network testnet --overwrite`);
24+
exe(`stellar keys generate alice --network testnet --overwrite --fund`);
2525

2626
// get the secret key of alice and put it in alice.txt
27-
exe(`${soroban} keys show alice > alice.txt`);
27+
exe(`stellar keys show alice > alice.txt`);
2828
}
2929

3030

@@ -34,19 +34,19 @@ function filenameNoExtension(filename) {
3434

3535
function deploy(wasm) {
3636

37-
let contractId = path.join(dirname, '.soroban', 'contract-ids', filenameNoExtension(wasm) + '.txt');
37+
let contractId = path.join(dirname, '.stellar', 'contract-ids', filenameNoExtension(wasm) + '.txt');
3838

39-
exe(`(${soroban} contract deploy --wasm ${wasm} --ignore-checks --source-account alice --network testnet) > ${contractId}`);
39+
exe(`(stellar contract deploy --wasm ${wasm} --ignore-checks --source-account alice --network testnet) > ${contractId}`);
4040
}
4141

4242
function deploy_all() {
43-
const contractsDir = path.join(dirname, '.soroban', 'contract-ids');
43+
const contractsDir = path.join(dirname, '.stellar', 'contract-ids');
4444
mkdirSync(contractsDir, { recursive: true });
4545

4646
let wasmFiles = readdirSync(`${dirname}`).filter(file => file.endsWith('.wasm'));
4747
console.log(dirname);
4848

49-
let rust_wasm = path.join('rust','target','wasm32-unknown-unknown', 'release-with-logs', 'hello_world.wasm');
49+
let rust_wasm = path.join('rust','target','wasm32v1-none', 'release-with-logs', 'hello_world.wasm');
5050

5151
// add rust wasm file to the list of wasm files
5252
wasmFiles.push(rust_wasm);
@@ -58,7 +58,7 @@ function deploy_all() {
5858

5959
function add_testnet() {
6060

61-
exe(`${soroban} network add \
61+
exe(`stellar network add \
6262
--global testnet \
6363
--rpc-url https://soroban-testnet.stellar.org:443 \
6464
--network-passphrase "Test SDF Network ; September 2015"`);

0 commit comments

Comments
 (0)