Skip to content

Instantly share code, notes, and snippets.

@patitonar
Created October 30, 2019 13:59
Show Gist options
  • Save patitonar/1af1e97d8cdd2e894da3e43db54e8737 to your computer and use it in GitHub Desktop.
Save patitonar/1af1e97d8cdd2e894da3e43db54e8737 to your computer and use it in GitHub Desktop.
Failing test that proves that setTotalSpentPerDay is called twice
it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is not owned by token manager', async function() {
// Given
const erc677Token = await ERC677BridgeToken.new('test', 'TST', 18)
await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled
contract = this.bridge
await contract.initialize(
bridgeContract.address,
mediatorContract.address,
erc677Token.address,
[dailyLimit, maxPerTx, minPerTx],
[executionDailyLimit, executionMaxPerTx],
maxGasPerTx,
decimalShiftZero,
owner
).should.be.fulfilled
const currentDay = await contract.getCurrentDay()
expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO)
const value = oneEther
await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled
expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value)
// When
await contract.relayTokens(user, value, { from: user }).should.be.fulfilled
// Then
const events = await getEvents(bridgeContract, { event: 'MockedEvent' })
expect(events.length).to.be.equal(1)
expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment