Skip to content

Commit

Permalink
Fixing bigint in MainModule test
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Jun 7, 2024
1 parent 4f04184 commit e753e4d
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions test/MainModule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract('MainModule', (accounts: string[]) => {
wallet = SequenceWallet.detailedWallet(context, { threshold: 1, signers: [wallet_a] })
await wallet.deploy()

const valA = 4123222
const valA = 4123222n
const valB = randomHex(99)

const transaction = {
Expand All @@ -103,7 +103,7 @@ contract('MainModule', (accounts: string[]) => {
wallet = SequenceWallet.detailedWallet(context, { threshold: 1, signers: [wallet_a, wallet_b] })
await wallet.deploy()

const valA = 4123222
const valA = 4123222n
const valB = randomHex(99)

const transaction = {
Expand All @@ -129,7 +129,7 @@ contract('MainModule', (accounts: string[]) => {
wallet = SequenceWallet.detailedWallet(context, { threshold: 1, signers: [wallet_a, singer_b] })
await wallet.deploy()

const valA = 4123222
const valA = 4123222n
const valB = randomHex(99)

const transaction = {
Expand Down Expand Up @@ -210,7 +210,7 @@ contract('MainModule', (accounts: string[]) => {

wallet = (await genWallet(0, c.childs, c.depth)) as SequenceWallet

const valA = 5423
const valA = 5423n
const valB = randomHex(120)

const transaction = {
Expand Down Expand Up @@ -284,7 +284,7 @@ contract('MainModule', (accounts: string[]) => {
})
await wallet.deploy()

const valA = 5423
const valA = 5423n
const valB = randomHex(120)

const transaction = {
Expand Down Expand Up @@ -638,8 +638,8 @@ contract('MainModule', (accounts: string[]) => {
.useConfig({ ...altWallet1.config, address: undefined })
.useSigners(altWallet1.signers)

expect(await wallet.mainModule.extraImageHash(altWallet1.imageHash)).to.equal(0)
expect(await wallet.mainModule.extraImageHash(altWallet2.imageHash)).to.equal(0)
expect(await wallet.mainModule.extraImageHash(altWallet1.imageHash)).to.equal(0n)
expect(await wallet.mainModule.extraImageHash(altWallet2.imageHash)).to.equal(0n)

await expect(badWallet1.sendTransactions([{}])).to.be.rejected
await expect(badWallet2.sendTransactions([{}])).to.be.rejected
Expand Down Expand Up @@ -841,7 +841,7 @@ contract('MainModule', (accounts: string[]) => {
})

describe('External calls', () => {
let { valA, valB } = { valA: Math.floor(Date.now()), valB: randomHex(120) }
let { valA, valB } = { valA: BigInt(Math.floor(Date.now())), valB: randomHex(120) }

it('Should perform call to contract', async () => {
const transaction = {
Expand All @@ -866,7 +866,7 @@ contract('MainModule', (accounts: string[]) => {
})
describe('Batch transactions', () => {
let callReceiver2: ContractType<typeof CallReceiverMock>
let { val2A, val2B } = { val2A: 9422, val2B: randomHex(31) }
let { val2A, val2B } = { val2A: 9422n, val2B: randomHex(31) }

beforeEach(async () => {
callReceiver2 = await CallReceiverMock.deploy()
Expand Down Expand Up @@ -911,7 +911,7 @@ contract('MainModule', (accounts: string[]) => {

expect(await callReceiver.lastValA()).to.equal(valA)
expect(await callReceiver.lastValB()).to.equal(valB)
expect(await hethers.provider.getBalance(receiver.address)).to.equal(26)
expect(await hethers.provider.getBalance(receiver.address)).to.equal(26n)
})

it('Should fail if one transaction fails', async () => {
Expand Down Expand Up @@ -967,7 +967,7 @@ contract('MainModule', (accounts: string[]) => {
}

const val = BigInt(receipt.logs.slice(-2)[0].data)
expect(val).to.equal(45)
expect(val).to.equal(45n)
})

describe('on delegate call revert', () => {
Expand Down Expand Up @@ -1023,16 +1023,16 @@ contract('MainModule', (accounts: string[]) => {
}

await wallet.sendTransactions([transaction])
expect(await hethers.provider.getBalance(receiver)).to.equal(25)
expect(await hethers.provider.getBalance(receiver)).to.equal(25n)
})

it('Should call payable function', async () => {
const signer = await hethers.provider.getSigner()
signer.sendTransaction({ to: wallet.address, value: 100 })

const valA = 63129
const valA = 63129n
const valB = randomHex(120)
const value = 33
const value = 33n

const transaction = {
target: await callReceiver.getAddress(),
Expand Down Expand Up @@ -1072,7 +1072,7 @@ contract('MainModule', (accounts: string[]) => {

describe('With multiple transactions', () => {
let callReceiver2: ContractType<typeof CallReceiverMock>
const { valA, valB } = { valA: 912341, valB: randomHex(30) }
const { valA, valB } = { valA: 912341n, valB: randomHex(30) }

beforeEach(async () => {
callReceiver2 = await CallReceiverMock.deploy()
Expand Down Expand Up @@ -1273,7 +1273,7 @@ contract('MainModule', (accounts: string[]) => {

it('Should forward call to external hook', async () => {
const walletHook = HookMock.attach(wallet.address)
expect(await walletHook.onHookMockCall(21)).to.equal(42)
expect(await walletHook.onHookMockCall(21)).to.equal(42n)
})

it('Should not forward call to deregistered hook', async () => {
Expand Down Expand Up @@ -2058,16 +2058,16 @@ contract('MainModule', (accounts: string[]) => {
it('Should execute multiple internal bundles', async () => {
const data = [
[
{ i: 0, a: 142, b: 412 },
{ i: 1, a: 123, b: 2 }
{ i: 0, a: 142n, b: 412 },
{ i: 1, a: 123n, b: 2 }
],
[
{ i: 2, a: 142, b: 2 },
{ i: 3, a: 642, b: 33 },
{ i: 4, a: 122, b: 12 },
{ i: 5, a: 611, b: 53 }
{ i: 2, a: 142n, b: 2 },
{ i: 3, a: 642n, b: 33 },
{ i: 4, a: 122n, b: 12 },
{ i: 5, a: 611n, b: 53 }
],
[{ i: 6, a: 2, b: 1 }],
[{ i: 6, a: 2n, b: 1 }],
[]
]

Expand Down Expand Up @@ -2134,8 +2134,8 @@ contract('MainModule', (accounts: string[]) => {

await wallet.sendTransactions(transactions)

expect(await callReceiver.lastValA()).to.equal(11)
expect(await callReceiver2.lastValA()).to.equal(12)
expect(await callReceiver.lastValA()).to.equal(11n)
expect(await callReceiver2.lastValA()).to.equal(12n)

expect(await callReceiver.lastValB()).to.equal(expected1)
expect(await callReceiver2.lastValB()).to.equal(expected2)
Expand Down Expand Up @@ -2182,9 +2182,9 @@ contract('MainModule', (accounts: string[]) => {

await wallet.sendTransactions(transaction)

expect(await callReceiver.lastValA()).to.equal(0)
expect(await callReceiver2.lastValA()).to.equal(0)
expect(await callReceiver3.lastValA()).to.equal(51)
expect(await callReceiver.lastValA()).to.equal(0n)
expect(await callReceiver2.lastValA()).to.equal(0n)
expect(await callReceiver3.lastValA()).to.equal(51n)

expect(await callReceiver.lastValB()).to.equal('0x')
expect(await callReceiver2.lastValB()).to.equal('0x')
Expand Down

0 comments on commit e753e4d

Please sign in to comment.