Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,4 @@ jobs:
- name: Run ts tests
run: |
npm install -g yarn
# TODO: update bodhi & enable this
# make test-ts
make test-ts
10 changes: 5 additions & 5 deletions ts-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"build": "waffle waffle.json"
},
"dependencies": {
"@acala-network/api": "6.1.3",
"@acala-network/bodhi": "~2.8.9",
"@acala-network/chopsticks": "^0.13.3",
"@acala-network/api": "6.3.0",
"@acala-network/bodhi": "~2.10.0",
"@acala-network/chopsticks": "^1.2.3",
"@openzeppelin/contracts": "5.0.2",
"@polkadot/api": "12.4.1",
"@polkadot/api": "16.4.8",
"ethereum-waffle": "4.0.10",
"ethers": "5.7.2",
"vitest": "^2.0.5"
"vitest": "^3.2.4"
},
"packageManager": "[email protected]"
}
24 changes: 24 additions & 0 deletions ts-tests/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
process.on('unhandledRejection', (reason: any) => {
const message = reason?.message || String(reason);

if (
message.includes('Normal Closure') ||
message.includes('disconnected from ws://')
) {
return;
}

console.error('Unhandled Rejection:', reason);
throw reason;
});

process.on('uncaughtException', (error: Error) => {
if (
error.message.includes('Normal Closure') ||
error.message.includes('disconnected from ws://')
) {
return;
}
console.error('Uncaught Exception:', error);
throw error;
});
14 changes: 7 additions & 7 deletions ts-tests/tests/test-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ describeWithAcala("Acala RPC (Balance)", (context) => {
});

it("genesis balance is setup correctly", async function () {
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999995648303331000000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999995648303331000000");
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999995072568421000000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999995072568421000000");

expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString())
.to.equal((await context.provider.api.query.system.account(alice.substrateAddress)).data.free.toString() + "000000");
});

it("balance to be updated after transfer", async function () {
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999995648303331000000");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000995648309012000000");
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999995072568421000000");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000995072575531000000");

await transfer(context, alice.substrateAddress, alice_stash.substrateAddress, 1000);
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999991609227300000000");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000995648310012000000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999991609227300000000");
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999990446773722000000");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000995072576531000000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999990446773722000000");
expect((await context.provider.getBalance(alice_stash.getAddress(), "earliest")).toString()).to.equal("0");
});
});
2 changes: 1 addition & 1 deletion ts-tests/tests/test-evm-create-fill-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ describeWithAcala("Acala RPC (EVM create fill block)", (context) => {

const evmCreateEvents = events.events.filter((item) => context.provider.api.events.evm.Created.is(item.event));

expect(evmCreateEvents.length).to.equal(225);
expect(evmCreateEvents.length).to.equal(216);
});
});
4 changes: 2 additions & 2 deletions ts-tests/tests/test-gas-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ describeWithAcala("Acala RPC (GasLimit)", (context) => {
const contract = await deployContract(alice, Factory);
// limited by used_storage
const result = await contract.createContractLoop(350);
expect(result.gasLimit.toNumber()).toMatchInlineSnapshot(`3928498122`);
expect(result.gasLimit.toNumber()).toMatchInlineSnapshot(`3928198122`);

const result2 = await contract.incrementLoop(8130);
expect(result2.gasLimit.toNumber()).toMatchInlineSnapshot(`32506508`);
expect(result2.gasLimit.toNumber()).toMatchInlineSnapshot(`32206508`);

const storages = await context.provider.api.query.evm.accountStorages.entries(contract.address);
// 350 array items
Expand Down
8 changes: 4 additions & 4 deletions ts-tests/tests/test-mempool-priority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ describeWithAcala("Acala RPC (Mempool Priority Order)", (context) => {

const operationalTransactionvalidity = await context.provider.api.call.taggedTransactionQueue.validateTransaction(
"Local",
tx3.toHex(),
tx3.toU8a(),
parentHash
);

expect(operationalTransactionvalidity).toMatchInlineSnapshot(`
{
"ok": {
"longevity": 31,
"priority": "0x0119dfa51d01f600",
"priority": "0x010543655f7f0900",
"propagate": true,
"provides": [
"0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d03000000",
Expand All @@ -96,7 +96,7 @@ describeWithAcala("Acala RPC (Mempool Priority Order)", (context) => {
await tx4.signAsync(alice.substrateAddress, { nonce: nonce + 2 });
const normalTransactionvalidity = await context.provider.api.call.taggedTransactionQueue.validateTransaction(
"Local",
tx4.toHex(),
tx4.toU8a(),
parentHash
);
expect(normalTransactionvalidity.toHuman()).toMatchInlineSnapshot(`
Expand All @@ -120,7 +120,7 @@ describeWithAcala("Acala RPC (Mempool Priority Order)", (context) => {
);
const unsignedTransactionvalidity = await context.provider.api.call.taggedTransactionQueue.validateTransaction(
"Local",
tx5.toHex(),
tx5.toU8a(),
parentHash
);

Expand Down
7 changes: 4 additions & 3 deletions ts-tests/tests/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Blockchain, BuildBlockMode, setupWithServer } from "@acala-network/chopsticks";
import { BodhiProvider, BodhiSigner, getTestUtils } from "@acala-network/bodhi";
import { BodhiProvider } from "@acala-network/eth-providers";
import { BodhiSigner, getTestUtils } from "@acala-network/bodhi";
import { Option } from '@polkadot/types/codec';
import { EvmAccountInfo } from '@acala-network/types/interfaces';
import { AddressOrPair, SubmittableExtrinsic } from "@polkadot/api/types";
Expand All @@ -21,7 +22,7 @@ export async function startAcalaNode(sealing = true, autoClaim = true): Promise<
'runtime-log-level': 0,
});

const { provider, wallets } = await getTestUtils(`ws://127.0.0.1:${server.listenPort}`, autoClaim);
const { provider, wallets } = await getTestUtils(`ws://${server.addr}`, autoClaim);

if (!sealing) {
server.chain.txPool.mode = BuildBlockMode.Manual;
Expand Down Expand Up @@ -53,7 +54,7 @@ export function describeWithAcala(title: string, cb: (context: TestContext) => v

afterAll(async function () {
// console.log(`\x1b[31m Killing RPC\x1b[0m`);
await context.provider.api.disconnect()
await context.provider.api.disconnect();
await context.close();
});

Expand Down
1 change: 1 addition & 0 deletions ts-tests/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default defineConfig({
pool: 'forks',
passWithNoTests: true,
include: ['tests/**/test-*.{js,ts}'],
setupFiles: ['./tests/setup.ts']
},
})
Loading