Skip to content

Commit

Permalink
chore: update flextesa test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ac10n committed Oct 27, 2023
1 parent f1442a1 commit 5a1cc63
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
testnet: nairobinet
testnet_uppercase: NAIROBINET
flextesa_docker_image: oxheadalpha/flextesa:20230607
env:
TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000
POLLING_INTERVAL_MILLISECONDS: 100
RPC_CACHE_MILLISECONDS: 0
TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down Expand Up @@ -112,19 +117,15 @@ jobs:
--protocol-kind ${{ matrix.protocol }}
- run: npm ci
- run: npm run build
- run: npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:flextesa:${{ matrix.testnet }}
- run: npm -w integration-tests run test:originate-known-contracts
env:
RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true
SECRET_KEY: edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2
TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000
POLLING_INTERVAL_MILLISECONDS: 100
RPC_CACHE_MILLISECONDS: 0
TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
- run: npm -w integration-tests run test:flextesa:${{ matrix.testnet }} -- --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts sandbox-ballot-operation.spec.ts
env:
RUN_${{ matrix.testnet_uppercase }}_WITH_FLEXTESA: true
SECRET_KEY: edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2
- run: npm -w integration-tests run test:${{ matrix.testnet }}-secret-key sandbox-ballot-operation.spec.ts
env:
RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true
RUN_${{ matrix.testnet_uppercase }}_WITH_FLEXTESA: true
SECRET_KEY: edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq
TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000
POLLING_INTERVAL_MILLISECONDS: 100
RPC_CACHE_MILLISECONDS: 0
TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
26 changes: 19 additions & 7 deletions integration-tests/local-keygen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ export class KeygenServer {
let keygen = this.keygenMap.get(key);
if (!keygen) {
keygen = new LocalKeygen(key, passphrase);
console.log(`Created new keygen for ${key}`);
// console.log(`Created new keygen for ${key}`);
this.keygenMap.set(key, keygen);
}
const newKey = await keygen.getKey();
reply.send(newKey);
});

this.fastify.get('/stats', (_request, reply) => {
const items = Array.from(this.keygenMap.entries());
reply.send({ total: this.keygenMap.size, stats: items.map(k => ({ name: k[0], stats: k[1].getStats() })) });
});

await this.fastify.listen({ port: 20001, host: 'localhost' }, (err, _address) => {
if (err) {
throw err;
}
// console.log(`Server is now listening on ${address}`);
});
}

async stopServer() {
await this.fastify.close();
for (const keygen of this.keygenMap.values()) {
keygen.cleanup();
}
await this.fastify.close();
}
}

Expand All @@ -46,10 +50,10 @@ class LocalKeygen {
private _keysQueue: string[] = [];
private _tezos: TezosToolkit;
private _creatingSigners = false;
private _batchSize = 20;
private _minCount = 10;
private _maxCount = 100;
private _batchSize = 15;
private _maxCount = 50;
private _interval: NodeJS.Timeout;
private _totalCreated = 0;

constructor(key: string, passphrase?: string) {
this._tezos = new TezosToolkit('http://localhost:20000');
Expand All @@ -75,7 +79,7 @@ class LocalKeygen {
return;
}
}
console.log(`creating ${count} signers, current queue size ${this._keysQueue.length}`);
// console.log(`creating ${count} signers, current queue size ${this._keysQueue.length}`);
this._creatingSigners = true;
try {
const keys: string[] = [];
Expand All @@ -93,11 +97,19 @@ class LocalKeygen {
const op = await transfers.send();
await op.confirmation();
this._keysQueue.push(...keys);
this._totalCreated += keys.length;
} finally {
this._creatingSigners = false;
}
}

getStats() {
return {
totalCreated: this._totalCreated,
queueSize: this._keysQueue.length
}
}

public async getKey(): Promise<string> {
for (let iteration = 0; iteration < 200; iteration++) {
const key = this._keysQueue.pop();
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"test:nairobinet": "NAIROBINET=true jest",
"test:nairobinet-secret-key": "RUN_NAIROBINET_WITH_SECRET_KEY=true jest --runInBand",
"test:originate-known-contracts": "node -r ts-node/register originate-known-contracts.ts",
"test:flextesa:nairobinet": "source ./sandbox-env.sh && jest -w 8 --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts sandbox-ballot-operation.spec.ts",
"test:flextesa:nairobinet": "RUN_NAIROBINET_WITH_FLEXTESA=true jest --forceExit -w 4",
"originate-known-contracts-and-run-test": "node -r ts-node/register originate-known-contracts.ts && jest",
"test:mondaynet": "MONDAYNET=true jest",
"test:mondaynet-secret-key": "RUN_MONDAYNET_WITH_SECRET_KEY=true jest --runInBand",
Expand Down
1 change: 0 additions & 1 deletion integration-tests/sandbox-env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
export RUN_NAIROBINET_WITH_FLEXTESA=true
export SECRET_KEY=edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx
export TEZOS_RPC_NAIROBINET=http://localhost:20000
export POLLING_INTERVAL_MILLISECONDS=100
Expand Down

0 comments on commit 5a1cc63

Please sign in to comment.