Skip to content

Commit 581b32a

Browse files
authored
Use renamed custom types example contract (#1043)
The custom-types contract was renamed in stellar/soroban-examples#322. The e2e end tests have been failing since then. This uses the renamed example contract to fix the tests. This also updates the pinned version of Stellar CLI. The latest CLI fixes the bug that two tests were working around, so we no longer need these tests.
1 parent 3e081ba commit 581b32a

File tree

4 files changed

+4
-96
lines changed

4 files changed

+4
-96
lines changed

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# paths = ["/path/to/override"] # path dependency overrides
22

33
[alias] # command aliases
4-
install_soroban = "install --version 21.0.0-rc.1 --root ./target soroban-cli --debug"
4+
install_soroban = "install --version 21.4.1 --root ./target soroban-cli --debug"
55
# b = "build --target wasm32-unknown-unknown --release"
66
# c = "check"
77
# t = "test"

test/e2e/initialize.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ target_dir="$dirname/test-contracts/target/wasm32-unknown-unknown/release"
4949
contracts_dir="$dirname/test-contracts"
5050
repo_url="https://github.com/stellar/soroban-examples.git"
5151
wasm_files=(
52-
"soroban_custom_types_contract.wasm"
52+
"soroban_other_custom_types_contract.wasm"
5353
"soroban_atomic_swap_contract.wasm"
5454
"soroban_token_contract.wasm"
5555
"soroban_increment_contract.wasm"
@@ -84,7 +84,7 @@ done
8484
if [ "$all_exist" = false ] || [ "$current_hash" != "$stored_hash" ]; then
8585
echo "WASM files are missing or contracts have been updated. Initializing and building contracts..."
8686
# Initialize contracts
87-
$soroban contract init "$dirname/test-contracts" --with-example increment custom_types atomic_swap token
87+
$soroban contract init "$dirname/test-contracts" --with-example increment other_custom_types atomic_swap token
8888

8989
# Change directory to test-contracts and build the contracts
9090
cd "$dirname/test-contracts" || { echo "Failed to change directory!"; exit 1; }

test/e2e/src/test-swap.js

-92
Original file line numberDiff line numberDiff line change
@@ -99,98 +99,6 @@ describe("Swap Contract Tests", function () {
9999
});
100100
});
101101

102-
it("modified & re-simulated transactions show updated data", async function () {
103-
const tx = await this.context.swapContractAsRoot.swap({
104-
a: this.context.alice.publicKey(),
105-
b: this.context.bob.publicKey(),
106-
token_a: this.context.tokenAId,
107-
token_b: this.context.tokenBId,
108-
amount_a: amountAToSwap,
109-
min_a_for_b: amountAToSwap,
110-
amount_b: amountBToSwap,
111-
min_b_for_a: amountBToSwap,
112-
});
113-
await tx.signAuthEntries({
114-
publicKey: this.context.alice.publicKey(),
115-
...contract.basicNodeSigner(this.context.alice, networkPassphrase),
116-
});
117-
await tx.signAuthEntries({
118-
publicKey: this.context.bob.publicKey(),
119-
...contract.basicNodeSigner(this.context.bob, networkPassphrase),
120-
});
121-
122-
const originalResourceFee = Number(
123-
tx.simulationData.transactionData.resourceFee(),
124-
);
125-
const bumpedResourceFee = originalResourceFee + 10000;
126-
127-
tx.raw = TransactionBuilder.cloneFrom(tx.built, {
128-
fee: tx.built.fee,
129-
sorobanData: new SorobanDataBuilder(
130-
tx.simulationData.transactionData.toXDR(),
131-
)
132-
.setResourceFee(
133-
xdr.Int64.fromString(bumpedResourceFee.toString()).toBigInt(),
134-
)
135-
.build(),
136-
});
137-
138-
await tx.simulate();
139-
140-
const newSimulatedResourceFee = Number(
141-
tx.simulationData.transactionData.resourceFee(),
142-
);
143-
144-
expect(originalResourceFee).to.not.equal(newSimulatedResourceFee);
145-
expect(newSimulatedResourceFee).to.be.greaterThan(bumpedResourceFee);
146-
});
147-
148-
it("modified & re-simulated transactions show updated data", async function () {
149-
const tx = await this.context.swapContractAsRoot.swap({
150-
a: this.context.alice.publicKey(),
151-
b: this.context.bob.publicKey(),
152-
token_a: this.context.tokenAId,
153-
token_b: this.context.tokenBId,
154-
amount_a: amountAToSwap,
155-
min_a_for_b: amountAToSwap,
156-
amount_b: amountBToSwap,
157-
min_b_for_a: amountBToSwap,
158-
});
159-
await tx.signAuthEntries({
160-
publicKey: this.context.alice.publicKey(),
161-
...contract.basicNodeSigner(this.context.alice, networkPassphrase),
162-
});
163-
await tx.signAuthEntries({
164-
publicKey: this.context.bob.publicKey(),
165-
...contract.basicNodeSigner(this.context.bob, networkPassphrase),
166-
});
167-
168-
const originalResourceFee = Number(
169-
tx.simulationData.transactionData.resourceFee(),
170-
);
171-
const bumpedResourceFee = originalResourceFee + 10000;
172-
173-
tx.raw = TransactionBuilder.cloneFrom(tx.built, {
174-
fee: tx.built.fee,
175-
sorobanData: new SorobanDataBuilder(
176-
tx.simulationData.transactionData.toXDR(),
177-
)
178-
.setResourceFee(
179-
xdr.Int64.fromString(bumpedResourceFee.toString()).toBigInt(),
180-
)
181-
.build(),
182-
});
183-
184-
await tx.simulate();
185-
186-
const newSimulatedResourceFee = Number(
187-
tx.simulationData.transactionData.resourceFee(),
188-
);
189-
190-
expect(originalResourceFee).to.not.equal(newSimulatedResourceFee);
191-
expect(newSimulatedResourceFee).to.be.greaterThan(bumpedResourceFee);
192-
});
193-
194102
it("alice swaps bob 10 A for 1 B", async function () {
195103
const tx = await this.context.swapContractAsRoot.swap({
196104
a: this.context.alice.publicKey(),

test/e2e/src/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const contracts = {
1010
"contract",
1111
"install",
1212
"--wasm",
13-
`${basePath}/soroban_custom_types_contract.wasm`,
13+
`${basePath}/soroban_other_custom_types_contract.wasm`,
1414
],
1515
{ shell: true, encoding: "utf8" },
1616
).stdout.trim(),

0 commit comments

Comments
 (0)