From 43a5da32720b37ba97ec03d7c144feba8d568285 Mon Sep 17 00:00:00 2001 From: Cuong Truong Date: Tue, 7 Nov 2023 16:59:34 +0800 Subject: [PATCH 1/2] modification to smart contract tests --- tests/StateRelayer.data.spec.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/StateRelayer.data.spec.ts b/tests/StateRelayer.data.spec.ts index 1c10c14..ca7d58f 100644 --- a/tests/StateRelayer.data.spec.ts +++ b/tests/StateRelayer.data.spec.ts @@ -1,13 +1,13 @@ import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; -import { loadFixture, time } from '@nomicfoundation/hardhat-network-helpers'; +import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import { expect } from 'chai'; -import { StateRelayer, StateRelayer__factory } from '../generated'; +import { StateRelayer, IStateRelayer, StateRelayer__factory } from '../generated'; import { deployContract } from './utils/deployment'; -type MasterNodeInformationStruct = StateRelayer.MasterNodeInformationStruct; -type VaultGeneralInformation = StateRelayer.VaultGeneralInformationStruct; -type DexInfo = StateRelayer.DEXInfoStruct; +type MasterNodeInformationStruct = IStateRelayer.MasterNodeInformationStruct; +type VaultGeneralInformation = IStateRelayer.VaultGeneralInformationStruct; +type DexInfo = IStateRelayer.DEXInfoStruct; describe('State relayer contract data tests', () => { let stateRelayerProxy: StateRelayer; @@ -296,5 +296,17 @@ describe('State relayer contract data tests', () => { `AccessControl: account ${(await stateRelayerProxy.getAddress()).toLowerCase()} is missing role ${botRole}`, ); }); + + it('Return right error when not using the right call data', async () => { + ({ stateRelayerProxy, bot } = await loadFixture(deployContract)); + // check if 0xffffffff is among the signatures of the contract + expect(StateRelayer__factory.createInterface().hasFunction('0xffffffff')).to.be.false; + + // use non-existent function signature + await expect(stateRelayerProxy.connect(bot).batchCallByBot(['0xffffffff'])).to.revertedWithCustomError( + stateRelayerProxy, + 'ERROR_IN_LOW_LEVEL_CALLS()', + ); + }); }); }); From 45e6339a43c55719e382be1314df1a9be50909e7 Mon Sep 17 00:00:00 2001 From: Cuong Truong Date: Wed, 8 Nov 2023 17:49:34 +0800 Subject: [PATCH 2/2] change package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b250fd..217391a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waveshq/state-relayer-bot", - "version": "0.0.0-beta.5", + "version": "0.0.1", "private": false, "main": "dist/index.js", "types": "dist/index.d.ts",