difftreelog
tests: eth_getCode
in: master
5 files changed
tests/src/apiConsts.test.tsdiffbeforeafterboth--- a/tests/src/apiConsts.test.ts
+++ b/tests/src/apiConsts.test.ts
@@ -15,7 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {ApiPromise} from '@polkadot/api';
-import {usingPlaygrounds, itSub, expect} from './util';
+import {usingPlaygrounds, itSub, expect, COLLECTION_HELPER, CONTRACT_HELPER} from './util';
const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;
@@ -40,9 +40,6 @@
ownerCanDestroy: true,
transfersEnabled: true,
};
-
-const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
-const HELPERS_CONTRACT_ADDRESS = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';
describe('integration test: API UNIQUE consts', () => {
let api: ApiPromise;
@@ -106,11 +103,11 @@
});
itSub('HELPERS_CONTRACT_ADDRESS', () => {
- expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(HELPERS_CONTRACT_ADDRESS.toLowerCase());
+ expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(CONTRACT_HELPER.toLowerCase());
});
itSub('EVM_COLLECTION_HELPERS_ADDRESS', () => {
- expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS.toLowerCase());
+ expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(COLLECTION_HELPER.toLowerCase());
});
});
tests/src/eth/collectionHelperAddress.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionHelperAddress.test.ts
+++ b/tests/src/eth/collectionHelperAddress.test.ts
@@ -16,9 +16,7 @@
import {itEth, usingEthPlaygrounds, expect} from './util';
import {IKeyringPair} from '@polkadot/types/types';
-import {Pallets} from '../util';
-
-const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
+import {COLLECTION_HELPER, Pallets} from '../util';
describe('[eth]CollectionHelperAddress test: ERC20/ERC721 ', () => {
let donor: IKeyringPair;
@@ -36,7 +34,7 @@
const nftCollection = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);
expect((await nftCollection.methods.collectionHelperAddress().call())
- .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+ .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
});
itEth.ifWithPallets('RFT ', [Pallets.ReFungible], async ({helper}) => {
@@ -46,7 +44,7 @@
const rftCollection = await helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);
expect((await rftCollection.methods.collectionHelperAddress().call())
- .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+ .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
});
itEth('FT', async ({helper}) => {
@@ -56,7 +54,7 @@
const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
expect((await collection.methods.collectionHelperAddress().call())
- .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+ .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
});
itEth('[collectionHelpers] convert collectionId into address', async ({helper}) => {
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth1// 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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';19import {expect, itEth, usingEthPlaygrounds} from './util';20import {CollectionLimitField} from './util/playgrounds/types';212223describe('Create NFT collection from EVM', () => {24 let donor: IKeyringPair;2526 before(async function () {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 });30 });3132 itEth('Create collection with properties & get desctription', async ({helper}) => {33 const owner = await helper.eth.createAccountWithBalance(donor);3435 const name = 'CollectionEVM';36 const description = 'Some description';37 const prefix = 'token prefix';38 const baseUri = 'BaseURI';3940 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);41 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');4243 expect(events).to.be.deep.equal([44 {45 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',46 event: 'CollectionCreated',47 args: {48 owner: owner,49 collectionId: collectionAddress,50 },51 },52 ]);5354 const collection = helper.nft.getCollectionObject(collectionId);55 const data = (await collection.getData())!;5657 expect(data.name).to.be.eq(name);58 expect(data.description).to.be.eq(description);59 expect(data.raw.tokenPrefix).to.be.eq(prefix);60 expect(data.raw.mode).to.be.eq('NFT');6162 expect(await contract.methods.description().call()).to.deep.equal(description);6364 const options = await collection.getOptions();65 expect(options.tokenPropertyPermissions).to.be.deep.equal([66 {67 key: 'URI',68 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},69 },70 {71 key: 'URISuffix',72 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},73 },74 ]);75 });7677 // Soft-deprecated78 itEth('[eth] Set sponsorship', async ({helper}) => {79 const owner = await helper.eth.createAccountWithBalance(donor);80 const sponsor = await helper.eth.createAccountWithBalance(donor);81 const ss58Format = helper.chain.getChainProperties().ss58Format;82 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');8384 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 await collection.methods.setCollectionSponsor(sponsor).send();8687 let data = (await helper.nft.getData(collectionId))!;88 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));8990 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');9192 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);93 await sponsorCollection.methods.confirmCollectionSponsorship().send();9495 data = (await helper.nft.getData(collectionId))!;96 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));97 });9899 itEth('[cross] Set sponsorship & get description', async ({helper}) => {100 const owner = await helper.eth.createAccountWithBalance(donor);101 const sponsor = await helper.eth.createAccountWithBalance(donor);102 const ss58Format = helper.chain.getChainProperties().ss58Format;103 const description = 'absolutely anything';104 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');105106 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);107 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);108 await collection.methods.setCollectionSponsorCross(sponsorCross).send();109110 let data = (await helper.nft.getData(collectionId))!;111 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));112113 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');114115 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);116 await sponsorCollection.methods.confirmCollectionSponsorship().send();117118 data = (await helper.nft.getData(collectionId))!;119 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));120121 expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);122 });123124 itEth('Collection address exist', async ({helper}) => {125 const owner = await helper.eth.createAccountWithBalance(donor);126 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';127 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);128129 expect(await collectionHelpers130 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())131 .to.be.false;132133 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');134 expect(await collectionHelpers135 .methods.isCollectionExist(collectionAddress).call())136 .to.be.true;137138 // check collectionOwner:139 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);140 const collectionOwner = await collectionEvm.methods.collectionOwner().call();141 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));142 });143});144145describe('(!negative tests!) Create NFT collection from EVM', () => {146 let donor: IKeyringPair;147 let nominal: bigint;148149 before(async function () {150 await usingEthPlaygrounds(async (helper, privateKey) => {151 donor = await privateKey({filename: __filename});152 nominal = helper.balance.getOneTokenNominal();153 });154 });155156 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {157 const owner = await helper.eth.createAccountWithBalance(donor);158 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);159 {160 const MAX_NAME_LENGTH = 64;161 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);162 const description = 'A';163 const tokenPrefix = 'A';164165 await expect(collectionHelper.methods166 .createNFTCollection(collectionName, description, tokenPrefix)167 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);168169 }170 {171 const MAX_DESCRIPTION_LENGTH = 256;172 const collectionName = 'A';173 const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);174 const tokenPrefix = 'A';175 await expect(collectionHelper.methods176 .createNFTCollection(collectionName, description, tokenPrefix)177 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);178 }179 {180 const MAX_TOKEN_PREFIX_LENGTH = 16;181 const collectionName = 'A';182 const description = 'A';183 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);184 await expect(collectionHelper.methods185 .createNFTCollection(collectionName, description, tokenPrefix)186 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);187 }188 });189190 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {191 const owner = await helper.eth.createAccountWithBalance(donor);192 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);193 await expect(collectionHelper.methods194 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')195 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');196 });197198 // Soft-deprecated199 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {200 const owner = await helper.eth.createAccountWithBalance(donor);201 const malfeasant = helper.eth.createAccount();202 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');203 const malfeasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);204 const EXPECTED_ERROR = 'NoPermission';205 {206 const sponsor = await helper.eth.createAccountWithBalance(donor);207 await expect(malfeasantCollection.methods208 .setCollectionSponsor(sponsor)209 .call()).to.be.rejectedWith(EXPECTED_ERROR);210211 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);212 await expect(sponsorCollection.methods213 .confirmCollectionSponsorship()214 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');215 }216 {217 await expect(malfeasantCollection.methods218 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: 1000}})219 .call()).to.be.rejectedWith(EXPECTED_ERROR);220 }221 });222223 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {224 const owner = await helper.eth.createAccountWithBalance(donor);225 const malfeasant = helper.eth.createAccount();226 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');227 const malfeasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);228 const EXPECTED_ERROR = 'NoPermission';229 {230 const sponsor = await helper.eth.createAccountWithBalance(donor);231 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);232 await expect(malfeasantCollection.methods233 .setCollectionSponsorCross(sponsorCross)234 .call()).to.be.rejectedWith(EXPECTED_ERROR);235236 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);237 await expect(sponsorCollection.methods238 .confirmCollectionSponsorship()239 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');240 }241 {242 await expect(malfeasantCollection.methods243 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: 1000}})244 .call()).to.be.rejectedWith(EXPECTED_ERROR);245 }246 });247248 itEth('destroyCollection', async ({helper}) => {249 const owner = await helper.eth.createAccountWithBalance(donor);250 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');251 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);252253254 const result = await collectionHelper.methods255 .destroyCollection(collectionAddress)256 .send({from: owner});257258 const events = helper.eth.normalizeEvents(result.events);259260 expect(events).to.be.deep.equal([261 {262 address: collectionHelper.options.address,263 event: 'CollectionDestroyed',264 args: {265 collectionId: collectionAddress,266 },267 },268 ]);269270 expect(await collectionHelper.methods271 .isCollectionExist(collectionAddress)272 .call()).to.be.false;273 expect(await helper.collection.getData(collectionId)).to.be.null;274 });275});tests/src/eth/getCode.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/eth/getCode.test.ts
@@ -0,0 +1,53 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {expect, itEth, usingEthPlaygrounds} from './util';
+import {IKeyringPair} from '@polkadot/types/types';
+import {COLLECTION_HELPER, CONTRACT_HELPER} from '../util';
+
+describe('RPC eth_getCode', () => {
+ let donor: IKeyringPair;
+
+ before(async function() {
+ await usingEthPlaygrounds(async (helper, privateKey) => {
+ donor = await privateKey({filename: __filename});
+ });
+ });
+
+ [
+ {address: COLLECTION_HELPER, expectedCode: '0x60e0604052602660808181529061073160a03960019061001f90826100d1565b5034801561002c57600080fd5b50610190565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061005c57607f821691505b60208210810361007c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100cc57600081815260208120601f850160051c810160208610156100a95750805b601f850160051c820191505b818110156100c8578281556001016100b5565b5050505b505050565b81516001600160401b038111156100ea576100ea610032565b6100fe816100f88454610048565b84610082565b602080601f831160018114610133576000841561011b5750858301515b600019600386901b1c1916600185901b1785556100c8565b600085815260208120601f198616915b8281101561016257888601518255948401946001909101908401610143565b50858210156101805787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6105928061019f6000396000f3fe6080604052600436106100915760003560e01c80638562425811610059578063856242581461013c578063ab1734501461012e578063b5cb749814610157578063c3de149414610187578063d23a7ab1146101a257600080fd5b806301ffc9a7146100965780632e716683146100cb578063564e321f146100fe5780637335b79f14610120578063844af6581461012e575b600080fd5b3480156100a257600080fd5b506100b66100b1366004610206565b6101c5565b60405190151581526020015b60405180910390f35b3480156100d757600080fd5b506100e66100b1366004610237565b6040516001600160a01b0390911681526020016100c2565b34801561010a57600080fd5b5061011e610119366004610279565b6101eb565b005b6100e66100b1366004610337565b6100e66100b13660046103da565b34801561014857600080fd5b5061011e610119366004610462565b34801561016357600080fd5b506101726100b1366004610279565b60405163ffffffff90911681526020016100c2565b34801561019357600080fd5b506100b66100b1366004610279565b3480156101ae57600080fd5b506101b76101c5565b6040519081526020016100c2565b6000600160405162461bcd60e51b81526004016101e291906104b0565b60405180910390fd5b600160405162461bcd60e51b81526004016101e291906104b0565b60006020828403121561021857600080fd5b81356001600160e01b03198116811461023057600080fd5b9392505050565b60006020828403121561024957600080fd5b813563ffffffff8116811461023057600080fd5b80356001600160a01b038116811461027457600080fd5b919050565b60006020828403121561028b57600080fd5b6102308261025d565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126102bb57600080fd5b813567ffffffffffffffff808211156102d6576102d6610294565b604051601f8301601f19908116603f011681019082821181831017156102fe576102fe610294565b8160405283815286602085880101111561031757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561034d57600080fd5b843567ffffffffffffffff8082111561036557600080fd5b610371888389016102aa565b95506020870135915060ff8216821461038957600080fd5b9093506040860135908082111561039f57600080fd5b6103ab888389016102aa565b935060608701359150808211156103c157600080fd5b506103ce878288016102aa565b91505092959194509250565b6000806000606084860312156103ef57600080fd5b833567ffffffffffffffff8082111561040757600080fd5b610413878388016102aa565b9450602086013591508082111561042957600080fd5b610435878388016102aa565b9350604086013591508082111561044b57600080fd5b50610458868287016102aa565b9150509250925092565b6000806040838503121561047557600080fd5b61047e8361025d565b9150602083013567ffffffffffffffff81111561049a57600080fd5b6104a6858286016102aa565b9150509250929050565b600060208083526000845481600182811c9150808316806104d257607f831692505b85831081036104ef57634e487b7160e01b85526022600452602485fd5b87860183815260200181801561050c57600181146105225761054d565b60ff198616825284151560051b8201965061054d565b60008b81526020902060005b868110156105475781548482015290850190890161052e565b83019750505b5094999850505050505050505056fea2646970667358221220a43ca09fe677b7ab611be4b7ea2ed7e656ade53b3d1252c653ff4a84b36d3c3064736f6c634300081000337468697320636f6e747261637420697320696d706c656d656e74656420696e206e6174697665'},
+ {address: CONTRACT_HELPER, expectedCode: '0x60e0604052602660808181529061073060a03960019061001f90826100d1565b5034801561002c57600080fd5b50610190565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061005c57607f821691505b60208210810361007c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100cc57600081815260208120601f850160051c810160208610156100a95750805b601f850160051c820191505b818110156100c8578281556001016100b5565b5050505b505050565b81516001600160401b038111156100ea576100ea610032565b6100fe816100f88454610048565b84610082565b602080601f831160018114610133576000841561011b5750858301515b600019600386901b1c1916600185901b1785556100c8565b600085815260208120601f198616915b8281101561016257888601518255948401946001909101908401610143565b50858210156101805787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6105918061019f6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c8063766c4f37116100ad578063c772ef6c11610071578063c772ef6c14610171578063ef7842501461022d578063f01fba931461023b578063f29694d814610249578063fde8a5601461026c57600080fd5b8063766c4f37146101dd57806377b6c9081461021f57806389f7d9ae1461022d5780639741860314610171578063abc000011461022d57600080fd5b80634706cc1c116100f45780634706cc1c1461017f5780635152b14c1461018d5780635c658165146101b35780636027dc611461017157806375b73606146101c157600080fd5b806301ffc9a71461012657806303aed6651461014e57806336de20f51461016357806339b9b24214610171575b600080fd5b6101396101343660046102fd565b61027a565b60405190151581526020015b60405180910390f35b61016161015c36600461034a565b6102a0565b005b61016161015c366004610384565b6101396101343660046103b7565b61016161015c3660046103d2565b61019b6101343660046103b7565b6040516001600160a01b039091168152602001610145565b610139610134366004610415565b6101cf6101343660046103b7565b604051908152602001610145565b6101f06101eb3660046103b7565b6102bb565b6040805182511515815260209283015180516001600160a01b0316848301529092015190820152606001610145565b61016161015c36600461043f565b61016161015c3660046103b7565b61016161015c366004610415565b6102576101343660046103b7565b60405163ffffffff9091168152602001610145565b61016161015c36600461047f565b6000600160405162461bcd60e51b815260040161029791906104af565b60405180910390fd5b600160405162461bcd60e51b815260040161029791906104af565b6102a060405180604001604052806000151581526020016102f8604051806040016040528060006001600160a01b03168152602001600081525090565b905290565b60006020828403121561030f57600080fd5b81356001600160e01b03198116811461032757600080fd5b9392505050565b80356001600160a01b038116811461034557600080fd5b919050565b6000806040838503121561035d57600080fd5b6103668361032e565b946020939093013593505050565b8035801515811461034557600080fd5b6000806040838503121561039757600080fd5b6103a08361032e565b91506103ae60208401610374565b90509250929050565b6000602082840312156103c957600080fd5b6103278261032e565b6000806000606084860312156103e757600080fd5b6103f08461032e565b92506103fe6020850161032e565b915061040c60408501610374565b90509250925092565b6000806040838503121561042857600080fd5b6104318361032e565b91506103ae6020840161032e565b6000806040838503121561045257600080fd5b61045b8361032e565b9150602083013563ffffffff8116811461047457600080fd5b809150509250929050565b6000806040838503121561049257600080fd5b61049b8361032e565b915060208301356003811061047457600080fd5b600060208083526000845481600182811c9150808316806104d157607f831692505b85831081036104ee57634e487b7160e01b85526022600452602485fd5b87860183815260200181801561050b57600181146105215761054c565b60ff198616825284151560051b8201965061054c565b60008b81526020902060005b868110156105465781548482015290850190890161052d565b83019750505b5094999850505050505050505056fea264697066735822122063505542f1c4602234fba58885c20aae30258ff8096b7f974a5563c90ad4a6c464736f6c634300081000337468697320636f6e747261637420697320696d706c656d656e74656420696e206e6174697665'},
+ ].map(testCase => {
+ itEth(`returns value for native contract: ${testCase.address}`, async ({helper}) => {
+ const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [testCase.address])).toJSON();
+ const contractCodeEth = (await helper.getWeb3().eth.getCode(testCase.address));
+
+ expect(contractCodeSub).to.eq(testCase.expectedCode);
+ expect(contractCodeEth).to.eq(testCase.expectedCode);
+ });
+ });
+
+ itEth('returns value for custom contract', async ({helper}) => {
+ const signer = await helper.eth.createAccountWithBalance(donor);
+ const flipper = await helper.eth.deployFlipper(signer);
+
+ const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [flipper.options.address])).toJSON();
+ const contractCodeEth = (await helper.getWeb3().eth.getCode(flipper.options.address));
+
+ expect(contractCodeSub).to.eq('0x6080604052348015600f57600080fd5b506004361060325760003560e01c806320965255146037578063cde4efa9146051575b600080fd5b603d6059565b6040516048919060b1565b60405180910390f35b6057606f565b005b60008060009054906101000a900460ff16905090565b60008054906101000a900460ff16156000806101000a81548160ff021916908315150217905550565b60008115159050919050565b60ab816098565b82525050565b600060208201905060c4600083018460a4565b9291505056fea264697066735822122077b6e0181f948cf0762391122339dd11290f54d8fd71596e8fe216ba8577e9f164736f6c63430008110033');
+ expect(contractCodeEth).to.eq('0x6080604052348015600f57600080fd5b506004361060325760003560e01c806320965255146037578063cde4efa9146051575b600080fd5b603d6059565b6040516048919060b1565b60405180910390f35b6057606f565b005b60008060009054906101000a900460ff16905090565b60008054906101000a900460ff16156000806101000a81548160ff021916908315150217905550565b60008115159050919050565b60ab816098565b82525050565b600060208201905060c4600083018460a4565b9291505056fea264697066735822122077b6e0181f948cf0762391122339dd11290f54d8fd71596e8fe216ba8577e9f164736f6c63430008110033');
+ });
+});
tests/src/util/index.tsdiffbeforeafterboth--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -100,6 +100,9 @@
export const LOCKING_PERIOD = 12n; // 12 blocks of relay
export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain
+// Native contracts
+export const COLLECTION_HELPER = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
+export const CONTRACT_HELPER = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';
export enum Pallets {
Inflation = 'inflation',