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

fix test flow #296

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions test/utils/HexUtils.js → test/utils/TestHexUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('HexUtils', () => {
})
it('Correctly parses all hex characters', async () => {
let [bytes32, valid] = await HexUtils.hexStringToBytes32(
toUtf8Bytes('0123456789abcdefABCDEF'),
toUtf8Bytes('0123456789abcdefABCDEF0123456789abcdefABCD'),
0,
22,
40,
)
expect(bytes32).to.equal(
'0x0000000000000000000000000000000000000000000123456789abcdefabcdef',
'0x0000000000000000000000000123456789abcdefabcdef0123456789abcdefab',
)
expect(valid).to.equal(true)
})
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('HexUtils', () => {
})
})

describe.only('Special cases for hexStringToBytes32()', () => {
describe('Special cases for hexStringToBytes32()', () => {
const hex32Bytes =
'5cee339e13375638553bdf5a6e36ba80fb9f6a4f0783680884d92b558aa471da'
it('odd length 1', async () => {
Expand Down
17 changes: 13 additions & 4 deletions test/wrapper/Constraints.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ function shouldRespectConstraints(contracts, getSigners) {
const parentExpiry = await BaseRegistrar.nameExpires(labelhash('test1'))
await NameWrapper.setChildFuses(parentNode, childLabelHash, 0, MAX_EXPIRY)
const [, , expiry] = await NameWrapper.getData(childNode)
expect(expiry).to.be.bignumber.equal(parentExpiry.add(GRACE_PERIOD))
console.log('expiry', expiry)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this before merging

expect(expiry.toString()).to.be.equal(
parentExpiry.add(GRACE_PERIOD).toString(),
)
})

it('Parent can extend expiry with setSubnodeOwner()', async () => {
Expand All @@ -271,7 +274,9 @@ function shouldRespectConstraints(contracts, getSigners) {
MAX_EXPIRY,
)
const [, , expiry] = await NameWrapper.getData(childNode)
expect(expiry).to.be.bignumber.equal(parentExpiry.add(GRACE_PERIOD))
expect(expiry.toString()).to.be.equal(
parentExpiry.add(GRACE_PERIOD).toString(),
)
})

it('Parent can extend expiry with setSubnodeRecord()', async () => {
Expand All @@ -286,7 +291,9 @@ function shouldRespectConstraints(contracts, getSigners) {
MAX_EXPIRY,
)
const [, , expiry] = await NameWrapper.getData(childNode)
expect(expiry).to.be.bignumber.equal(parentExpiry.add(GRACE_PERIOD))
expect(expiry.toString()).to.be.equal(
parentExpiry.add(GRACE_PERIOD).toString(),
)
})
}

Expand All @@ -309,7 +316,9 @@ function shouldRespectConstraints(contracts, getSigners) {
const parentExpiry = await BaseRegistrar.nameExpires(labelhash('test1'))
await NameWrapper.setChildFuses(parentNode, childLabelHash, 0, MAX_EXPIRY)
const [, , expiry] = await NameWrapper.getData(childNode)
expect(expiry).to.be.bignumber.equal(parentExpiry.add(GRACE_PERIOD))
expect(expiry.toString()).to.be.equal(
parentExpiry.add(GRACE_PERIOD).toString(),
)
})

it('Parent cannot extend expiry with setSubnodeOwner()', async () => {
Expand Down
76 changes: 44 additions & 32 deletions test/wrapper/ERC1155.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,22 @@ function shouldBehaveLikeERC1155(
context("when accounts don't own tokens", function () {
it('returns zero for given addresses', async function () {
expect(
await token.balanceOf(firstTokenHolderAddress, firstTokenId),
).to.be.bignumber.equal('0')
(
await token.balanceOf(firstTokenHolderAddress, firstTokenId)
).toString(),
).to.be.equal('0')

expect(
await token.balanceOf(secondTokenHolderAddress, secondTokenId),
).to.be.bignumber.equal('0')
(
await token.balanceOf(secondTokenHolderAddress, secondTokenId)
).toString(),
).to.be.equal('0')

expect(
await token.balanceOf(firstTokenHolderAddress, unknownTokenId),
).to.be.bignumber.equal('0')
(
await token.balanceOf(firstTokenHolderAddress, unknownTokenId)
).toString(),
).to.be.equal('0')
})
})

Expand All @@ -95,16 +101,22 @@ function shouldBehaveLikeERC1155(

it('returns the amount of tokens owned by the given addresses', async function () {
expect(
await token.balanceOf(firstTokenHolderAddress, firstTokenId),
).to.be.bignumber.equal(firstAmount)
(
await token.balanceOf(firstTokenHolderAddress, firstTokenId)
).toString(),
).to.be.equal(firstAmount.toString())

expect(
await token.balanceOf(secondTokenHolderAddress, secondTokenId),
).to.be.bignumber.equal(secondAmount)
(
await token.balanceOf(secondTokenHolderAddress, secondTokenId)
).toString(),
).to.be.equal(secondAmount.toString())

expect(
await token.balanceOf(firstTokenHolderAddress, unknownTokenId),
).to.be.bignumber.equal('0')
(
await token.balanceOf(firstTokenHolderAddress, unknownTokenId)
).toString(),
).to.be.equal('0')
})
})
})
Expand Down Expand Up @@ -151,9 +163,9 @@ function shouldBehaveLikeERC1155(
[firstTokenId, secondTokenId, unknownTokenId],
)
expect(result).to.be.an('array')
expect(result[0]).to.be.a.bignumber.equal('0')
expect(result[1]).to.be.a.bignumber.equal('0')
expect(result[2]).to.be.a.bignumber.equal('0')
expect(result[0].toString()).to.be.equal('0')
expect(result[1].toString()).to.be.equal('0')
expect(result[2].toString()).to.be.equal('0')
})
})

Expand All @@ -172,9 +184,9 @@ function shouldBehaveLikeERC1155(
[secondTokenId, firstTokenId, unknownTokenId],
)
expect(result).to.be.an('array')
expect(result[0]).to.be.a.bignumber.equal(secondAmount)
expect(result[1]).to.be.a.bignumber.equal(firstAmount)
expect(result[2]).to.be.a.bignumber.equal('0')
expect(result[0].toString()).to.be.equal(secondAmount.toString())
expect(result[1].toString()).to.be.equal(firstAmount.toString())
expect(result[2].toString()).to.be.equal('0')
})

it('returns multiple times the balance of the same address when asked', async function () {
Expand All @@ -187,10 +199,10 @@ function shouldBehaveLikeERC1155(
[firstTokenId, secondTokenId, firstTokenId],
)
expect(result).to.be.an('array')
expect(result[0]).to.be.a.bignumber.equal(result[2])
expect(result[0]).to.be.a.bignumber.equal(firstAmount)
expect(result[1]).to.be.a.bignumber.equal(secondAmount)
expect(result[2]).to.be.a.bignumber.equal(firstAmount)
expect(result[0].toString()).to.be.equal(result[2].toString())
expect(result[0].toString()).to.be.equal(firstAmount.toString())
expect(result[1].toString()).to.be.equal(secondAmount.toString())
expect(result[2].toString()).to.be.equal(firstAmount.toString())
})
})
})
Expand Down Expand Up @@ -275,12 +287,12 @@ function shouldBehaveLikeERC1155(

it('debits transferred balance from sender', async function () {
const newBalance = await token.balanceOf(from, id)
expect(newBalance).to.be.a.bignumber.equal('0')
expect(newBalance.toString()).to.be.a.equal('0')
})

it('credits transferred balance to receiver', async function () {
const newBalance = await token.balanceOf(this.toWhom, id)
expect(newBalance).to.be.a.bignumber.equal(value)
expect(newBalance.toString()).to.be.a.equal(value.toString())
})

it('emits a TransferSingle log', async function () {
Expand Down Expand Up @@ -316,13 +328,13 @@ function shouldBehaveLikeERC1155(
multiTokenHolderAddress,
secondTokenId,
)
expect(balance1).to.be.a.bignumber.equal(secondAmount)
expect(balance1.toString()).to.be.equal(secondAmount.toString())

const balance2 = await token.balanceOf(
recipientAddress,
secondTokenId,
)
expect(balance2).to.be.a.bignumber.equal('0')
expect(balance2.toString()).to.be.a.bignumber.equal('0')
})
})

Expand Down Expand Up @@ -382,13 +394,13 @@ function shouldBehaveLikeERC1155(

it("preserves operator's balances not involved in the transfer", async function () {
const balance1 = await token.balanceOf(proxyAddress, firstTokenId)
expect(balance1).to.be.a.bignumber.equal('0')
expect(balance1.toString()).to.be.equal('0')

const balance2 = await token.balanceOf(
proxyAddress,
secondTokenId,
)
expect(balance2).to.be.a.bignumber.equal('0')
expect(balance2.toString()).to.be.equal('0')
})
})
},
Expand Down Expand Up @@ -615,7 +627,7 @@ function shouldBehaveLikeERC1155(
ids,
)
for (const newBalance of newBalances) {
expect(newBalance).to.be.a.bignumber.equal('0')
expect(newBalance.toString()).to.be.equal('0')
}
})

Expand All @@ -625,7 +637,7 @@ function shouldBehaveLikeERC1155(
ids,
)
for (let i = 0; i < newBalances.length; i++) {
expect(newBalances[i]).to.be.a.bignumber.equal(values[i])
expect(newBalances[i].toString()).to.be.equal(values[i].toString())
}
})

Expand Down Expand Up @@ -714,12 +726,12 @@ function shouldBehaveLikeERC1155(

it("preserves operator's balances not involved in the transfer", async function () {
const balance1 = await token.balanceOf(proxyAddress, firstTokenId)
expect(balance1).to.be.a.bignumber.equal('0')
expect(balance1.toString()).to.be.equal('0')
const balance2 = await token.balanceOf(
proxyAddress,
secondTokenId,
)
expect(balance2).to.be.a.bignumber.equal('0')
expect(balance2.toString()).to.be.equal('0')
})
})
},
Expand Down