Skip to content

Commit 75597e9

Browse files
authored
Fix E2E Test Errors (#2405)
# Goal The goal of this PR is to make the e2e tests work against Testnet on Paseo e2e Run against Testnet-Paseo: https://github.com/frequency-chain/frequency/actions/runs/15022918786 All green except for non-released features! # Discussion The main issue is that many things need to wait until finalization for the next thing to be able to consistently work. - Updated JS packages - Split up several e2e tests to parallelize - Update the setup of many e2e tests to run in parallel - Update the nonce setup to use Atomics so that it is "thread" safe - Increase timeouts as the tests take longer against a chain that takes time to finalize - Suppress expected rpc errors on sendUnsigned
1 parent 1d0baad commit 75597e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5452
-4542
lines changed

e2e/.mocharc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"exit": true,
3+
"fullTrace": true,
34
"extension": ["ts"],
45
"parallel": true,
56
"require": ["scaffolding/globalHooks.ts", "scaffolding/rootHooks.ts", "scaffolding/extrinsicHelpers.ts"],

e2e/.relay-chain-all.mocharc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"exit": true,
3+
"fullTrace": true,
34
"extension": ["ts"],
45
"parallel": true,
56
"require": ["scaffolding/globalHooks.ts", "scaffolding/rootHooks.ts", "scaffolding/extrinsicHelpers.ts"],
67
"import": "tsx/esm",
78
"spec": ["./{,!(node_modules|load-tests)/**}/*.test.ts"],
8-
"timeout": 180000
9+
"timeout": 300000
910
}

e2e/.relay-chain.mocharc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"exit": true,
3+
"fullTrace": true,
34
"extension": ["ts"],
45
"require": ["scaffolding/rootHooks.ts", "scaffolding/extrinsicHelpers.ts"],
56
"import": "tsx/esm",
6-
"timeout": 180000
7+
"timeout": 300000
78
}

e2e/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ Note: this is for the "createMsa" tests
1717

1818
See below for running load tests and relay chain tests.
1919

20+
Waiting for Finalization
21+
============================
22+
23+
Some actions require waiting for finalization before the next action can happen.
24+
25+
Example: Funding a key that will then take an action that uses that funding.
26+
27+
While sometimes this is not needed, it creates a race condition and sometimes the transaction pool will reject the
28+
second transaction as it is unfunded.
29+
30+
The transaction pool doesn't know when two transactions are dependent if they are not from the same account with the
31+
same nonce.
32+
33+
Make sure to wait for finalization before attempting the next dependent transaction.
34+
2035
Notes on E2E Testing
2136
============================
2237

e2e/capacity/capacityFail.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ describe('Capacity Transaction Failures', function () {
160160
// from the transaction pool.
161161
it('fails to pay for a transaction with empty capacity', async function () {
162162
const noCapacityKeys = createKeys('noCapacityKeys');
163-
const noCapacityProvider = await createMsaAndProvider(fundingSource, noCapacityKeys, 'NoCapProvider');
163+
const noCapacityProvider = await createMsaAndProvider(
164+
fundingSource,
165+
noCapacityKeys,
166+
'NoCapProvider',
167+
undefined,
168+
false
169+
);
164170

165171
const delegatorKeys = createKeys('delegatorKeys');
166172

e2e/capacity/change_staking_target.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ const fundingSource = getFundingSource(import.meta.url);
1515

1616
describe('Capacity: change_staking_target', function () {
1717
const tokenMinStake: bigint = 1n * CENTS;
18-
const capacityMin: bigint = tokenMinStake / 50n;
1918

2019
it('successfully stake tokens to a provider', async function () {
2120
const providerBalance = 2n * DOLLARS;
2221
const stakeKeys = createKeys('staker');
23-
const oldProvider = await createMsaAndProvider(fundingSource, stakeKeys, 'Provider1', providerBalance);
24-
const [_bar, newProvider] = await createProviderKeysAndId(fundingSource, providerBalance);
2522

23+
// Setup
24+
const [oldProvider, [_bar, newProvider]] = await Promise.all([
25+
createMsaAndProvider(fundingSource, stakeKeys, 'Provider1', providerBalance),
26+
createProviderKeysAndId(fundingSource, providerBalance),
27+
]);
28+
29+
// Stake
2630
await assert.doesNotReject(stakeToProvider(fundingSource, stakeKeys, oldProvider, tokenMinStake * 3n));
2731

32+
// Change Stake
2833
const call = ExtrinsicHelper.changeStakingTarget(stakeKeys, oldProvider, newProvider, tokenMinStake);
2934
const events = await call.signAndSend();
3035
assert.notEqual(events, undefined);

e2e/capacity/staking.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,12 @@ describe('Capacity Staking Tests', function () {
326326

327327
const vestedTransferTx = ExtrinsicHelper.timeReleaseTransfer(fundingSource, vesterKeys, schedule);
328328

329-
await assert.doesNotReject(vestedTransferTx.signAndSend());
329+
await assert.doesNotReject(vestedTransferTx.signAndSend(undefined, undefined, false));
330330
await assertFrozen(vesterKeys, 100n * DOLLARS);
331331

332-
await assert.doesNotReject(ExtrinsicHelper.stake(vesterKeys, providerId, 80n * DOLLARS).signAndSend());
332+
await assert.doesNotReject(
333+
ExtrinsicHelper.stake(vesterKeys, providerId, 80n * DOLLARS).signAndSend(undefined, undefined, false)
334+
);
333335

334336
const spendable = await getSpendableBalance(vesterKeys);
335337
// after txn fees

e2e/capacity/transactions.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ describe('Capacity Transactions', function () {
181181

182182
const { eventMap } = await call.payWithCapacity();
183183
assertEvent(eventMap, 'capacity.CapacityWithdrawn');
184-
assertEvent(eventMap, 'messages.MessagesInBlock');
184+
// messages.MessagesInBlock in block might not be on this transaction if there are others
185+
assertEvent(eventMap, 'system.ExtrinsicSuccess');
185186
});
186187

187188
it('successfully pays with Capacity for eligible transaction - addOnchainMessage', async function () {
@@ -190,7 +191,8 @@ describe('Capacity Transactions', function () {
190191
const call = ExtrinsicHelper.addOnChainMessage(capacityKeys, dummySchemaId, '0xdeadbeef');
191192
const { eventMap } = await call.payWithCapacity();
192193
assertEvent(eventMap, 'capacity.CapacityWithdrawn');
193-
assertEvent(eventMap, 'messages.MessagesInBlock');
194+
// messages.MessagesInBlock in block might not be on this transaction if there are others
195+
assertEvent(eventMap, 'system.ExtrinsicSuccess');
194196
const get = await ExtrinsicHelper.apiPromise.rpc.messages.getBySchemaId(dummySchemaId, {
195197
from_block: starting_block,
196198
from_index: 0,

e2e/eslint.config.mjs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,13 @@
33
import eslint from '@eslint/js';
44
import globals from 'globals';
55
import tseslint from 'typescript-eslint';
6-
import mocha from 'eslint-plugin-mocha';
7-
8-
// Needed for eslint 9
9-
const mochaConfig = [
10-
{
11-
name: 'mocha/recommended',
12-
languageOptions: {
13-
globals: globals.mocha,
14-
},
15-
plugins: {
16-
mocha,
17-
},
18-
rules: mocha.configs.flat.recommended.rules,
19-
},
20-
];
6+
import mochaPlugin from 'eslint-plugin-mocha';
217

228
export default tseslint.config(
239
eslint.configs.recommended,
10+
mochaPlugin.configs.recommended,
2411
...tseslint.configs.strict,
2512
...tseslint.configs.stylistic,
26-
...mochaConfig,
2713
{
2814
ignores: ['dist/'],
2915
},

0 commit comments

Comments
 (0)