1234567891011121314151617import {expect, itEth, usingEthPlaygrounds} from './util/index.js';18import type {IKeyringPair} from '@polkadot/types/types';19import {COLLECTION_HELPER, CONTRACT_HELPER} from '../util/index.js';2021describe('RPC eth_getCode', () => {22 let donor: IKeyringPair;2324 before(async function() {25 await usingEthPlaygrounds(async (_, privateKey) => {26 donor = await privateKey({url: import.meta.url});27 });28 });2930 [31 {address: COLLECTION_HELPER},32 {address: CONTRACT_HELPER},33 ].map(testCase => {34 itEth(`returns value for native contract: ${testCase.address}`, async ({helper}) => {35 const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [testCase.address])).toJSON();36 const contractCodeEth = (await helper.getWeb3().eth.getCode(testCase.address));3738 expect(contractCodeSub).to.has.length.greaterThan(4);39 expect(contractCodeEth).to.has.length.greaterThan(4);40 });41 });4243 itEth('returns value for custom contract', async ({helper}) => {44 const signer = await helper.eth.createAccountWithBalance(donor);45 const flipper = await helper.eth.deployFlipper(signer);4647 const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [flipper.options.address])).toJSON();48 const contractCodeEth = (await helper.getWeb3().eth.getCode(flipper.options.address));4950 expect(contractCodeSub).to.has.length.greaterThan(4);51 expect(contractCodeEth).to.has.length.greaterThan(4);52 });53});