Skip to content

Commit

Permalink
Add chain id mock tu
Browse files Browse the repository at this point in the history
  • Loading branch information
sydhds committed Dec 22, 2023
1 parent 35ec5e6 commit adeba37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions assembly/__tests__/vm-mock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { changeCallStack, resetStorage } from '../vm-mock/storage';
import {
mockAdminContext,
mockSetChainId,
setDeployContext,
setLocalContext,
} from '../vm-mock/env';
Expand Down Expand Up @@ -290,3 +291,18 @@ describe('Testing mocked Context', () => {
);
});
});

describe('Testing mocked Chain id', () => {
beforeEach(() => {
mockSetChainId(9_000_000);
});

afterAll(() => {
mockSetChainId(77);
});

it('chain id mock value', () => {
let chainId = env.chainId();
expect(env.chainId()).toBe(9_000_000);
});
});
2 changes: 1 addition & 1 deletion vm-mock/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ export default function createMockedABI(

const pubKeyBuf = getArrayBuffer(publicKeyPtr);
if (pubKeyBuf.byteLength !== 64) {
console.log('Invalid publickey length. Expected 64 bytes uncompressed secp256k1 public key');
console.log('Invalid public key length. Expected 64 bytes uncompressed secp256k1 public key');
throw new Error();
}

Expand Down

0 comments on commit adeba37

Please sign in to comment.