1234567891011121314151617import {expect} from 'chai';18import {submitTransactionAsync} from '../substrate/substrate-api';19import {createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';2021describe('EVM Migrations', () => {22 itWeb3('Deploy contract saved state', async ({web3, api, privateKeyWrapper}) => {23 242526272829303132333435363738394041424344 const ADDRESS = '0x4956bf52ef9ed8789f21bc600e915e0d961079f6';45 const CODE = '0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ab06ee514610051578063371303c01461006d5780637bfdec3b146100775780639507d39a14610095575b600080fd5b61006b60048036038101906100669190610160565b6100c5565b005b6100756100e1565b005b61007f6100f8565b60405161008c91906101af565b60405180910390f35b6100af60048036038101906100aa9190610133565b610101565b6040516100bc91906101af565b60405180910390f35b8060016000848152602001908152602001600020819055505050565b60016000546100f091906101ca565b600081905550565b60008054905090565b600060016000838152602001908152602001600020549050919050565b60008135905061012d8161025e565b92915050565b60006020828403121561014957610148610259565b5b60006101578482850161011e565b91505092915050565b6000806040838503121561017757610176610259565b5b60006101858582860161011e565b92505060206101968582860161011e565b9150509250929050565b6101a981610220565b82525050565b60006020820190506101c460008301846101a0565b92915050565b60006101d582610220565b91506101e083610220565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156102155761021461022a565b5b828201905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b61026781610220565b811461027257600080fd5b5056fea26469706673582212206a02d2fb5c244105ab884961479c1aee3b4c1011e4b5530ab483eb22344a865664736f6c63430008060033';46 const DATA = [47 48 ['0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000000000000000000000000000000000000000000a'],49 50 ['0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f', '0x0000000000000000000000000000000000000000000000000000000000000001'],51 ['0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f', '0x0000000000000000000000000000000000000000000000000000000000000002'],52 ['0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b', '0x0000000000000000000000000000000000000000000000000000000000000003'],53 ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],54 ];5556 const alice = privateKeyWrapper('//Alice');57 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);5859 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));60 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.setData(ADDRESS, DATA as any) as any));61 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.finish(ADDRESS, CODE) as any));6263 const contract = new web3.eth.Contract([64 {65 inputs: [],66 name: 'counterValue',67 outputs: [{68 internalType: 'uint256',69 name: '',70 type: 'uint256',71 }],72 stateMutability: 'view',73 type: 'function',74 },75 {76 inputs: [{77 internalType: 'uint256',78 name: 'key',79 type: 'uint256',80 }],81 name: 'get',82 outputs: [{83 internalType: 'uint256',84 name: '',85 type: 'uint256',86 }],87 stateMutability: 'view',88 type: 'function',89 },90 ], ADDRESS, {from: caller, ...GAS_ARGS});9192 expect(await contract.methods.counterValue().call()).to.be.equal('10');93 for (let i = 1; i <= 4; i++) {94 expect(await contract.methods.get(i).call()).to.be.equal(i.toString());95 }96 });97});