From d90cd8c20fbc67fed32629a7b67ca0c4f65544dc Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 7 Dec 2023 21:49:36 +0700 Subject: [PATCH] chore: test e2e --- .github/workflows/tests.yml | 3 +- .../src/services/AxelarRelayerService.ts | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 766f0060..14d08454 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,5 +55,4 @@ jobs: # nohup sh -c "sui-test-validator" > nohup.out 2> nohup.err < /dev/null & nohup sh -c "aptos node run-local-testnet --with-faucet" > nohup.out 2> nohup.err < /dev/null & sleep 10 - npm run test:cosmos - npm run test-e2e:cosmos + npm run test:e2e diff --git a/packages/axelar-local-dev-cosmos/src/services/AxelarRelayerService.ts b/packages/axelar-local-dev-cosmos/src/services/AxelarRelayerService.ts index 4db78201..56c4d17e 100644 --- a/packages/axelar-local-dev-cosmos/src/services/AxelarRelayerService.ts +++ b/packages/axelar-local-dev-cosmos/src/services/AxelarRelayerService.ts @@ -45,14 +45,19 @@ export class AxelarRelayerService extends Relayer { async listenForEvents() { if (this.listened) return; - this.axelarListener.listen(AxelarCosmosContractCallEvent, async (args) => { - this.updateCallContractEvents(args); - this.execute(this.commands); - }); + this.axelarListener.listen( + AxelarCosmosContractCallEvent, + this.handleContractCallEvent.bind(this) + ); this.listened = true; } + private async handleContractCallEvent(args: any) { + this.updateCallContractEvents(args); + await this.execute(this.commands); + } + async stopListening() { await this.axelarListener.stop(); @@ -151,11 +156,15 @@ export class AxelarRelayerService extends Relayer { ); } - private async executeEvmGateway( - to: Network, - commands: Command[] - ): Promise { - const data = arrayify( + private async executeEvmGateway(to: Network, commands: Command[]) { + const data = this.encodeGatewayData(to, commands); + const signedData = await getSignedExecuteInput(data, to.operatorWallet); + + return this.sendExecuteTransaction(to, signedData); + } + + private encodeGatewayData(to: Network, commands: Command[]) { + return arrayify( defaultAbiCoder.encode( ["uint256", "bytes32[]", "string[]", "bytes[]"], [ @@ -166,8 +175,9 @@ export class AxelarRelayerService extends Relayer { ] ) ); - const signedData = await getSignedExecuteInput(data, to.operatorWallet); + } + private async sendExecuteTransaction(to: Network, signedData: any) { return to.gateway .connect(to.ownerWallet) .execute(signedData, { gasLimit: BigInt(8e6) })