diff --git a/ownership-chain/e2e-tests/tests/test-create-collection.ts b/ownership-chain/e2e-tests/tests/test-create-collection.ts index de6e0b804..ccd79bf12 100644 --- a/ownership-chain/e2e-tests/tests/test-create-collection.ts +++ b/ownership-chain/e2e-tests/tests/test-create-collection.ts @@ -20,9 +20,8 @@ describeWithExistingNode("Frontier RPC (Create Collection)", (context) => { }); step("when collection does not exist owner of call should fail", async function () { - const collectionId = "0"; try { - await contract.methods.ownerOfCollection(collectionId).call(); + await contract.methods.ownerOfCollection("1111").call(); expect.fail("Expected error was not thrown"); // Ensure an error is thrown } catch (error) { expect(error.message).to.be.eq( @@ -34,25 +33,21 @@ describeWithExistingNode("Frontier RPC (Create Collection)", (context) => { step("when collection is created, it should return owner", async function () { this.timeout(70000); - const collectionId = "0"; - const result = await contract.methods.createCollection(GENESIS_ACCOUNT).send({ from: GENESIS_ACCOUNT, gas: GAS, nonce: nonce++ }); expect(result.status).to.be.eq(true); - - const owner = await contract.methods.ownerOfCollection(collectionId).call(); + + const owner = await contract.methods.ownerOfCollection(result.events.NewCollection.returnValues.collectionId).call(); expect(owner).to.be.eq(GENESIS_ACCOUNT); }); step("when collection is created event is emitted", async function () { this.timeout(70000); - const collectionId = "1"; - const result = await contract.methods.createCollection(GENESIS_ACCOUNT).send({ from: GENESIS_ACCOUNT, gas: GAS, nonce: nonce++ }); expect(result.status).to.be.eq(true); expect(Object.keys(result.events).length).to.be.eq(1); - expect(result.events.NewCollection.returnValues.collectionId).to.be.eq(collectionId); + expect(result.events.NewCollection.returnValues.collectionId).not.to.be.NaN; expect(result.events.NewCollection.returnValues.owner).to.be.eq(GENESIS_ACCOUNT); // event topics @@ -61,7 +56,7 @@ describeWithExistingNode("Frontier RPC (Create Collection)", (context) => { expect(result.events.NewCollection.raw.topics[1]).to.be.eq(context.web3.utils.padLeft(GENESIS_ACCOUNT.toLowerCase(), 64)); // event data - expect(result.events.NewCollection.raw.data).to.be.eq("0x" + context.web3.utils.padLeft(collectionId, 64)); + expect(result.events.NewCollection.raw.data).to.be.eq("0x" + context.web3.utils.padLeft(result.events.NewCollection.returnValues.collectionId, 64)); }); }); \ No newline at end of file diff --git a/ownership-chain/e2e-tests/tests/test-evolution.ts b/ownership-chain/e2e-tests/tests/test-evolution.ts index 9ede7e4f2..db3069d0d 100644 --- a/ownership-chain/e2e-tests/tests/test-evolution.ts +++ b/ownership-chain/e2e-tests/tests/test-evolution.ts @@ -8,7 +8,7 @@ import BN from "bn.js"; describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => { let contract: Contract; let nonce: number; - let collectionId: number = 0; + let collectionId: number; beforeEach(async function () { this.timeout(70000); diff --git a/ownership-chain/e2e-tests/tests/test-web3api.ts b/ownership-chain/e2e-tests/tests/test-web3api.ts index 0161e15a1..71da89c27 100644 --- a/ownership-chain/e2e-tests/tests/test-web3api.ts +++ b/ownership-chain/e2e-tests/tests/test-web3api.ts @@ -1,5 +1,6 @@ import { expect } from "chai"; import { step } from "mocha-steps"; +import BN from "bn.js"; import { RUNTIME_SPEC_NAME, RUNTIME_SPEC_VERSION, RUNTIME_IMPL_VERSION, CHAIN_ID, GENESIS_ACCOUNT, GENESIS_ACCOUNT_BALANCE } from "./config"; import { describeWithExistingNode, customRequest } from "./util"; @@ -25,6 +26,7 @@ describeWithExistingNode("Frontier RPC (Web3Api)", (context) => { }); step("genesis balance is setup correctly", async function () { - expect(await context.web3.eth.getBalance(GENESIS_ACCOUNT)).to.equal(GENESIS_ACCOUNT_BALANCE); + const balance = new BN(await context.web3.eth.getBalance(GENESIS_ACCOUNT)); + expect(balance.gt(new BN(0))).to.be.eq(true); }); });