git.delta.rocks / unique-network / refs/commits / d9af4aedc967

difftreelog

source

js-packages/tests/eth/getCode.test.ts2.2 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect, itEth, usingEthPlaygrounds} from '@unique/test-utils/eth/util.js';18import type {IKeyringPair} from '@polkadot/types/types';19import {COLLECTION_HELPER, CONTRACT_HELPER} from '@unique/test-utils/util.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});