Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E2E Tests for Asset Teleportation Between LAOS and Asset Hub with Configuration Updates #829

Merged
merged 99 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
c1de812
mercury sovereign account
asiniscalchi Oct 15, 2024
dfd43fd
fix compilation
asiniscalchi Oct 15, 2024
361dfec
adding test for zombienet sovereign address
asiniscalchi Oct 15, 2024
9c1cfb3
Merge branch 'main' into feature/zombienet_assetHub_has_to_be_1000
asiniscalchi Oct 15, 2024
34ccc9d
zombienet uses assehub for default
asiniscalchi Oct 15, 2024
fa1ed12
downloading polkadot-parachain
asiniscalchi Oct 15, 2024
c92b92f
set variable for asset hub
asiniscalchi Oct 15, 2024
1e97625
fix bin
asiniscalchi Oct 15, 2024
6db24f3
using a couple of collators
asiniscalchi Oct 15, 2024
ba6117a
wip
magecnion Oct 16, 2024
2e5cccf
add limited teleport asset call
magecnion Oct 16, 2024
6764d91
add limited teleport asset call
magecnion Oct 16, 2024
c0bdd02
test hrmp channels are open
magecnion Oct 17, 2024
c64a4f6
restore unnecesary changes
magecnion Oct 17, 2024
c0e6809
restore xcm-native file
magecnion Oct 17, 2024
589dd8a
WIP test teleport asset from laos to asset hub
magecnion Oct 17, 2024
d22d706
Merge remote-tracking branch 'origin/feature/zombienet_assetHub_has_t…
magecnion Oct 17, 2024
079d94d
test force the creation of hrmp channels
magecnion Oct 17, 2024
f81bf0d
edit xcm config and zombienet config file
luispdm Oct 17, 2024
3191faa
Merge remote-tracking branch 'origin/main' into feature/zombienet-tes…
magecnion Oct 17, 2024
63fc497
Merge remote-tracking branch 'origin/feature/laos-runtime-xcm' into f…
magecnion Oct 17, 2024
9e086db
add some logs
magecnion Oct 17, 2024
8a2c2b0
add setup file to e2e tests
magecnion Oct 18, 2024
e1770c1
merge main
magecnion Oct 22, 2024
5fd4705
restore unnecesary changes
magecnion Oct 22, 2024
e71dcbd
restore unnecesary changes
magecnion Oct 22, 2024
2e7d2f8
wip
magecnion Oct 22, 2024
16c59da
Adding withdrawasset + buyexecution to e2e create asset test
tsenovilla Oct 22, 2024
5b606aa
Prettier
tsenovilla Oct 22, 2024
2e24f44
read event with hardcoded call
magecnion Oct 22, 2024
72ccc32
build correct call
magecnion Oct 22, 2024
f45febc
finish create foreign asset test
magecnion Oct 23, 2024
e69a399
add exit so mocha exists when tests end
magecnion Oct 23, 2024
8510598
Merge remote-tracking branch 'origin/main' into feature/zombienet-tes…
magecnion Oct 23, 2024
527988a
no need of setup file anymore
magecnion Oct 23, 2024
92402ec
test send create pool xcm msg
magecnion Oct 24, 2024
9d4443e
create pool call is encoded properly
magecnion Oct 24, 2024
96249a9
refactor
magecnion Oct 25, 2024
53b35e8
check balances after creating foreign asset
magecnion Oct 25, 2024
4f24143
check balances after creating foreign asset
magecnion Oct 25, 2024
2758949
Using WS connection to Zombienet in order to receibe tx status/events
tsenovilla Oct 25, 2024
21a3b3e
Reveting to http provider for simplicity
tsenovilla Oct 25, 2024
1ffacd9
Waiting together for all blockchains producing blocks
tsenovilla Oct 25, 2024
615923c
Solving conflicts with test-create-pool
tsenovilla Oct 25, 2024
66ef5e4
Solving conflicts with test-create-pool
tsenovilla Oct 25, 2024
2b355a5
add mint step so ferdie owns laos in AH
magecnion Oct 25, 2024
9171385
Refactoring
tsenovilla Oct 25, 2024
84b5fa7
prettier
tsenovilla Oct 25, 2024
1c7b710
uncomment teleport
magecnion Oct 25, 2024
e55d0ab
add TODO comment
magecnion Oct 25, 2024
86ef003
some comments
magecnion Oct 25, 2024
3ca7fc1
Merge remote-tracking branch 'origin/feature/zombienet-test-asset-hub…
magecnion Oct 25, 2024
d94941f
Correct deposit in e2e teleport test
tsenovilla Oct 25, 2024
f330c2d
Adding refactors
tsenovilla Oct 25, 2024
074aa73
Solving typo
tsenovilla Oct 25, 2024
eb0591e
Solving typo
tsenovilla Oct 25, 2024
8e2f97d
test teleport back
magecnion Oct 28, 2024
0a80042
delete old line
magecnion Oct 28, 2024
f818ba0
refactor: resuse laosAssetId and remove chai-bn dep
magecnion Oct 29, 2024
425ae02
refactor: add waitForEvent fn
magecnion Oct 29, 2024
492497a
add some logs to tests
magecnion Oct 29, 2024
9927ec7
go back to 1seg of delay and set 15 waiting blocks for events
magecnion Oct 29, 2024
d2436b5
use checking account to disregard wrong event
magecnion Oct 29, 2024
0577023
format issues
magecnion Oct 29, 2024
4781976
use HttpProvider to prevent poltergeist
magecnion Oct 30, 2024
e9f49f0
increate timeout
magecnion Oct 30, 2024
465c591
go back to 600000 ms
magecnion Oct 30, 2024
9af68de
go back to 600000 ms
magecnion Oct 30, 2024
00ea838
remove comments
magecnion Oct 30, 2024
00d5052
apply suggestions
magecnion Oct 31, 2024
9afc54c
fix BN compare
magecnion Oct 31, 2024
814b7e6
Update readme
magecnion Oct 31, 2024
34a0d06
Merge remote-tracking branch 'origin/main' into feature/zombienet-tes…
magecnion Oct 31, 2024
a486e6c
fix: read events from canonical chain
magecnion Oct 31, 2024
e721314
Adding helpful structures
tsenovilla Oct 31, 2024
637207e
Merge branch 'feature/zombienet-test-asset-hub' of github.com:freever…
tsenovilla Oct 31, 2024
6f817d5
Adding data structures for networks
tsenovilla Nov 4, 2024
a019b2f
downgrade to 14.0.1
magecnion Nov 4, 2024
6571135
update and remove unused deps
magecnion Nov 4, 2024
f47c079
refactor test names
magecnion Nov 4, 2024
f49d0f8
npm fmt
magecnion Nov 4, 2024
9654de6
open polkadot connections only when needed
magecnion Nov 4, 2024
6fb877e
Using this to pass global context to tests
tsenovilla Nov 4, 2024
ec30dd4
fmt
magecnion Nov 5, 2024
6b55b6a
Merging main branch
tsenovilla Nov 5, 2024
2c9ab78
Solving typo
tsenovilla Nov 5, 2024
9c3cf11
Deleting repeated stuff
tsenovilla Nov 5, 2024
1ebaae4
Rename types
tsenovilla Nov 5, 2024
d9956d5
Resolve conflicts
tsenovilla Nov 5, 2024
f5fc96b
Moving mocha types to external file
tsenovilla Nov 5, 2024
b8fa356
Merge branch 'main' into feature/zombienet-test-asset-hub
tsenovilla Nov 5, 2024
308e2a2
Solving conflicts with main
tsenovilla Nov 12, 2024
e7bf14a
Merge branch 'main' into feature/zombienet-test-asset-hub
tsenovilla Nov 12, 2024
d317c71
Use this.ethereumPairs instead of the plain address along tests
tsenovilla Nov 12, 2024
a4dc200
fmt
tsenovilla Nov 12, 2024
f531255
increasing invalid tx wait
tsenovilla Nov 13, 2024
72fd14a
Managing all tx statuses
tsenovilla Nov 13, 2024
4c9f022
Managing future, retracted and finalityTimeout tx statuses
tsenovilla Nov 13, 2024
3688bf4
Managing future, retracted and finalityTimeout tx statuses
tsenovilla Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
run: |
export ZOMBIENET_RELAYCHAIN_COMMAND=./tmp/polkadot
export ZOMBIENET_LAOS_COMMAND=./target/release/laos
export ZOMBIENET_ASSETHUB_COMMAND=./tmp/polkadot-parachain
./zombienet-linux-x64 spawn ./zombienet/native.toml &
echo "Zombienet started"

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ node_modules/
frontier-test-tmp
build/

tmp/
tmp/
3,888 changes: 2,401 additions & 1,487 deletions e2e-tests/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"name": "ts-tests",
"name": "e2e-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"fmt-check": "prettier ./tests --check",
"fmt": "prettier ./tests --write",
"build": "./compile_contracts.sh",
"test": "mocha -r ts-node/register -t 600000 'tests/**/*.ts'",
"test": "mocha -r ts-node/register -t 900000 'tests/**/*.ts'",
"test-sql": "FRONTIER_BACKEND_TYPE='sql' mocha -r ts-node/register 'tests/**/*.ts'"
},
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "^14.2.3",
"@polkadot/api-augment": "^14.2.3",
"@polkadot/types": "^14.2.2",
"@polkadot/util": "^13.2.2",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"ethers": "^6.3.0",
"mocha": "^10.2.0",
"mocha-steps": "^1.3.0",
"rimraf": "^5.0.0",
"solc": "^0.8.3",
"truffle": "^5.11.5",
"ts-node": "^10.9.1",
Expand Down
9 changes: 6 additions & 3 deletions e2e-tests/tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import EvolutionCollection from "../build/contracts/EvolutionCollection.json";
import EvolutionCollectionFactory from "../build/contracts/EvolutionCollectionFactory.json";
import Vesting from "../build/contracts/Vesting.json";
import ParachainStaking from "../build/contracts/ParachainStaking.json";

// Node config
export const RUNTIME_SPEC_NAME = "laos";
export const RUNTIME_SPEC_VERSION = 2390;
export const RUNTIME_IMPL_VERSION = 0;
export const LOCAL_NODE_IP = "127.0.0.1:9999";
export const LAOS_NODE_IP = "127.0.0.1:9999";
export const ASSET_HUB_NODE_IP = "127.0.0.1:9950";
export const RELAYCHAIN_NODE_IP = "127.0.0.1:9944";

// Chain config
export const CHAIN_ID = 667;
export const GAS_PRICE = "0x3B9ACA00";
export const ASSET_HUB_PARA_ID = 1000;
export const LAOS_PARA_ID = 2900;

// Accounts
export const CHECKING_ACCOUNT = "0x6d6F646c70792F78636D63680000000000000000";
export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d";
export const FAITH_PRIVATE_KEY = "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df";
export const ALITH = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac";
Expand Down
37 changes: 19 additions & 18 deletions e2e-tests/tests/test-create-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,73 @@ import {
EVOLUTION_COLLECTION_FACTORY_CONTRACT_ADDRESS,
EVOLUTION_COLLECTION_FACTORY_ABI,
GAS_PRICE,
FAITH,
FAITH_PRIVATE_KEY,
REVERT_BYTECODE,
SELECTOR_LOG_NEW_COLLECTION,
} from "./config";
import { createCollection, describeWithExistingNode } from "./util";

describeWithExistingNode("Frontier RPC (Create Collection)", (context) => {
describeWithExistingNode("Frontier RPC (Create Collection)", function () {
let contract: Contract;
// This is the contract that is created in the test
let testCollectionContract: Contract;
// This is the address of another contract that is created in the test
let testCollectionAddress: string;

before(async function () {
contract = new context.web3.eth.Contract(
contract = new this.context.web3.eth.Contract(
EVOLUTION_COLLECTION_FACTORY_ABI,
EVOLUTION_COLLECTION_FACTORY_CONTRACT_ADDRESS,
{
from: FAITH,
from: this.ethereumPairs.faith.address,
gasPrice: GAS_PRICE,
}
);
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
});

step("when collection is created, it should return owner", async function () {
const collectionContract = await createCollection(context);
const collectionContract = await createCollection(this.context);
testCollectionContract = collectionContract;

const owner = await collectionContract.methods.owner().call();
expect(owner).to.be.eq(FAITH);
expect(owner).to.be.eq(this.ethereumPairs.faith.address);
});

step("when collection is created event is emitted", async function () {
const estimatedGas = await contract.methods.createCollection(FAITH).estimateGas();
const result = await contract.methods.createCollection(FAITH).send({
from: FAITH,
const estimatedGas = await contract.methods.createCollection(this.ethereumPairs.faith.address).estimateGas();
const result = await contract.methods.createCollection(this.ethereumPairs.faith.address).send({
from: this.ethereumPairs.faith.address,
gas: estimatedGas,
gasPrice: GAS_PRICE,
});
expect(result.status).to.be.eq(true);

expect(Object.keys(result.events).length).to.be.eq(1);
expect(context.web3.utils.isAddress(result.events.NewCollection.returnValues._collectionAddress)).to.be.eq(
expect(this.context.web3.utils.isAddress(result.events.NewCollection.returnValues._collectionAddress)).to.be.eq(
true
);
testCollectionAddress = result.events.NewCollection.returnValues._collectionAddress;
expect(result.events.NewCollection.returnValues._owner).to.be.eq(FAITH);
expect(result.events.NewCollection.returnValues._owner).to.be.eq(this.ethereumPairs.faith.address);

// event topics
expect(result.events.NewCollection.raw.topics.length).to.be.eq(2);
expect(result.events.NewCollection.raw.topics[0]).to.be.eq(SELECTOR_LOG_NEW_COLLECTION);
expect(result.events.NewCollection.raw.topics[1]).to.be.eq(context.web3.utils.padLeft(FAITH.toLowerCase(), 64));
expect(result.events.NewCollection.raw.topics[1]).to.be.eq(
this.context.web3.utils.padLeft(this.ethereumPairs.faith.address.toLowerCase(), 64)
);

// event data
expect(result.events.NewCollection.raw.data.toLowerCase()).to.be.eq(
context.web3.utils.padLeft(result.events.NewCollection.returnValues._collectionAddress, 64).toLowerCase()
this.context.web3.utils
.padLeft(result.events.NewCollection.returnValues._collectionAddress, 64)
.toLowerCase()
);
});

step("when collection is created, bytecode is inserted in the storage", async function () {
expect(await context.web3.eth.getCode(testCollectionContract.options.address)).to.be.eq(REVERT_BYTECODE);
expect(await context.web3.eth.getCode(testCollectionAddress)).to.be.eq(REVERT_BYTECODE);
expect(await this.context.web3.eth.getCode(testCollectionContract.options.address)).to.be.eq(REVERT_BYTECODE);
expect(await this.context.web3.eth.getCode(testCollectionAddress)).to.be.eq(REVERT_BYTECODE);

// non-contract address doesn't have any code
expect(await context.web3.eth.getCode(FAITH)).to.be.eq("0x");
expect(await this.context.web3.eth.getCode(this.ethereumPairs.faith.address)).to.be.eq("0x");
});
});
62 changes: 35 additions & 27 deletions e2e-tests/tests/test-evolution.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createCollection, describeWithExistingNode, slotAndOwnerToTokenId } from "./util";
import {
FAITH,
SELECTOR_LOG_EVOLVED_WITH_EXTERNAL_TOKEN_URI,
SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI,
SELECTOR_LOG_OWNERSHIP_TRANSFERRED,
Expand All @@ -10,11 +9,11 @@ import Contract from "web3-eth-contract";
import BN from "bn.js";
import { step } from "mocha-steps";

describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", function () {
let collectionContract: Contract;

beforeEach(async function () {
collectionContract = await createCollection(context);
collectionContract = await createCollection(this.context);
});

step("when collection does not exist token uri should fail", async function () {
Expand All @@ -32,14 +31,14 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {

step("when asset is minted it should return token uri", async function () {
const slot = "0";
const to = FAITH;
const to = this.ethereumPairs.faith.address;
const tokenURI = "https://example.com";

let nonce = await context.web3.eth.getTransactionCount(FAITH);
let nonce = await this.context.web3.eth.getTransactionCount(this.ethereumPairs.faith.address);
const estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
const result = await collectionContract.methods
.mintWithExternalURI(to, slot, tokenURI)
.send({ from: FAITH, gas: estimatedGas, nonce: nonce++ });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas, nonce: nonce++ });
expect(result.status).to.be.eq(true);

const tokenId = result.events.MintedWithExternalURI.returnValues._tokenId;
Expand All @@ -49,7 +48,7 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {

step("given slot and owner it should return token id", async function () {
const slot = "1";
const to = FAITH;
const to = this.ethereumPairs.faith.address;

const tokenId = slotAndOwnerToTokenId(slot, to);
expect(tokenId).to.be.eq("000000000000000000000001c0f0f4ab324c46e55d02d0033343b4be8a55532d");
Expand All @@ -59,13 +58,13 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {

step("when asset is minted it should emit an event", async function () {
const slot = "22";
const to = FAITH;
const to = this.ethereumPairs.faith.address;
const tokenURI = "https://example.com";

const estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
const result = await collectionContract.methods
.mintWithExternalURI(to, slot, tokenURI)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(result.status).to.be.eq(true);

expect(Object.keys(result.events).length).to.be.eq(1);
Expand All @@ -82,18 +81,21 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
expect(result.events.MintedWithExternalURI.raw.topics.length).to.be.eq(2);
expect(result.events.MintedWithExternalURI.raw.topics[0]).to.be.eq(SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI);
expect(result.events.MintedWithExternalURI.raw.topics[1]).to.be.eq(
context.web3.utils.padLeft(FAITH.toLowerCase(), 64)
this.context.web3.utils.padLeft(this.ethereumPairs.faith.address.toLowerCase(), 64)
);

// event data
expect(result.events.MintedWithExternalURI.raw.data).to.be.eq(
context.web3.eth.abi.encodeParameters(["uint96", "uint256", "string"], [slot, tokenIdDecimal, tokenURI])
this.context.web3.eth.abi.encodeParameters(
["uint96", "uint256", "string"],
[slot, tokenIdDecimal, tokenURI]
)
);
});

step("when asset is evolved it should change token uri", async function () {
const slot = "22";
const to = FAITH;
const to = this.ethereumPairs.faith.address;
const tokenURI = "https://example.com";
const newTokenURI = "https://new_example.com";
const tokenId = slotAndOwnerToTokenId(slot, to);
Expand All @@ -102,15 +104,15 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
var estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
const mintingResult = await collectionContract.methods
.mintWithExternalURI(to, slot, tokenURI)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(mintingResult.status).to.be.eq(true);

estimatedGas = await collectionContract.methods
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
.estimateGas();
const evolvingResult = await collectionContract.methods
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(evolvingResult.status).to.be.eq(true);

const got = await collectionContract.methods.tokenURI(tokenIdDecimal).call();
Expand All @@ -119,7 +121,7 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {

step("when asset is evolved it should emit an event", async function () {
const slot = "22";
const to = FAITH;
const to = this.ethereumPairs.faith.address;
const tokenURI = "https://example.com";
const newTokenURI = "https://new_example.com";
const tokenId = slotAndOwnerToTokenId(slot, to);
Expand All @@ -128,15 +130,15 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
var estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
const mintingResult = await collectionContract.methods
.mintWithExternalURI(to, slot, tokenURI)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(mintingResult.status).to.be.eq(true);

estimatedGas = await collectionContract.methods
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
.estimateGas();
const evolvingResult = await collectionContract.methods
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(evolvingResult.status).to.be.eq(true);

expect(Object.keys(evolvingResult.events).length).to.be.eq(1);
Expand All @@ -154,33 +156,35 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {

// event data
expect(evolvingResult.events.EvolvedWithExternalURI.raw.data).to.be.eq(
context.web3.eth.abi.encodeParameters(["string"], [newTokenURI])
this.context.web3.eth.abi.encodeParameters(["string"], [newTokenURI])
);
});
});

describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
describeWithExistingNode("Frontier RPC (Transfer Ownership)", function () {
let collectionContract: Contract;

before(async function () {
collectionContract = await createCollection(context);
collectionContract = await createCollection(this.context);
});

step("when is transferred owner should change and emit an event", async function () {
const newOwner = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac";

expect(await collectionContract.methods.owner().call()).to.be.eq(FAITH);
expect(await collectionContract.methods.owner().call()).to.be.eq(this.ethereumPairs.faith.address);
const estimatedGas = await collectionContract.methods.transferOwnership(newOwner).estimateGas();
const tranferringResult = await collectionContract.methods
.transferOwnership(newOwner)
.send({ from: FAITH, gas: estimatedGas });
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect(tranferringResult.status).to.be.eq(true);
expect(await collectionContract.methods.owner().call()).to.be.eq(newOwner);

expect(Object.keys(tranferringResult.events).length).to.be.eq(1);

// data returned within the event
expect(tranferringResult.events.OwnershipTransferred.returnValues._previousOwner).to.be.eq(FAITH);
expect(tranferringResult.events.OwnershipTransferred.returnValues._previousOwner).to.be.eq(
this.ethereumPairs.faith.address
);
expect(tranferringResult.events.OwnershipTransferred.returnValues._newOwner).to.be.eq(newOwner);

// event topics
Expand All @@ -189,17 +193,21 @@ describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
SELECTOR_LOG_OWNERSHIP_TRANSFERRED
);
expect(tranferringResult.events.OwnershipTransferred.raw.topics[1]).to.be.eq(
context.web3.utils.padLeft(FAITH.toLowerCase(), 64)
this.context.web3.utils.padLeft(this.ethereumPairs.faith.address.toLowerCase(), 64)
);
expect(tranferringResult.events.OwnershipTransferred.raw.topics[2]).to.be.eq(
context.web3.utils.padLeft(newOwner.toLowerCase(), 64)
this.context.web3.utils.padLeft(newOwner.toLowerCase(), 64)
);
// event data
expect(tranferringResult.events.OwnershipTransferred.raw.data).to.be.eq("0x");

try {
const estimatedGas = await collectionContract.methods.transferOwnership(FAITH).estimateGas();
await collectionContract.methods.transferOwnership(FAITH).send({ from: FAITH, gas: estimatedGas });
const estimatedGas = await collectionContract.methods
.transferOwnership(this.ethereumPairs.faith.address)
.estimateGas();
await collectionContract.methods
.transferOwnership(this.ethereumPairs.faith.address)
.send({ from: this.ethereumPairs.faith.address, gas: estimatedGas });
expect.fail("Expected error was not thrown"); // Ensure an error is thrown
} catch (error) {
expect(error.message).to.eq(
Expand Down
Loading
Loading