Browse Source

Check all errors in eth tests

feature/sql-semaphore1
Eduard S 4 years ago
parent
commit
ebecc5c671
3 changed files with 188 additions and 95 deletions
  1. +52
    -26
      eth/auction_test.go
  2. +100
    -51
      eth/rollup_test.go
  3. +36
    -18
      eth/wdelayer_test.go

+ 52
- 26
eth/auction_test.go

@ -71,8 +71,10 @@ func TestAuctionSetSlotDeadline(t *testing.T) {
slotDeadline, err := auctionClientTest.AuctionGetSlotDeadline()
require.Nil(t, err)
assert.Equal(t, newSlotDeadline, slotDeadline)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newSlotDeadline, auctionEvents.NewSlotDeadline[0].NewSlotDeadline)
}
@ -90,8 +92,10 @@ func TestAuctionSetOpenAuctionSlots(t *testing.T) {
openAuctionSlots, err := auctionClientTest.AuctionGetOpenAuctionSlots()
require.Nil(t, err)
assert.Equal(t, newOpenAuctionSlots, openAuctionSlots)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newOpenAuctionSlots, auctionEvents.NewOpenAuctionSlots[0].NewOpenAuctionSlots)
}
@ -109,8 +113,10 @@ func TestAuctionSetClosedAuctionSlots(t *testing.T) {
closedAuctionSlots, err := auctionClientTest.AuctionGetClosedAuctionSlots()
require.Nil(t, err)
assert.Equal(t, newClosedAuctionSlots, closedAuctionSlots)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newClosedAuctionSlots, auctionEvents.NewClosedAuctionSlots[0].NewClosedAuctionSlots)
_, err = auctionClientTest.AuctionSetClosedAuctionSlots(closedAuctionSlots)
require.Nil(t, err)
@ -130,8 +136,10 @@ func TestAuctionSetOutbidding(t *testing.T) {
outbidding, err := auctionClientTest.AuctionGetOutbidding()
require.Nil(t, err)
assert.Equal(t, newOutbidding, outbidding)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newOutbidding, auctionEvents.NewOutbidding[0].NewOutbidding)
_, err = auctionClientTest.AuctionSetOutbidding(outbiddingConst)
require.Nil(t, err)
@ -151,8 +159,10 @@ func TestAuctionSetAllocationRatio(t *testing.T) {
allocationRatio, err := auctionClientTest.AuctionGetAllocationRatio()
require.Nil(t, err)
assert.Equal(t, newAllocationRatio, allocationRatio)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newAllocationRatio, auctionEvents.NewAllocationRatio[0].NewAllocationRatio)
_, err = auctionClientTest.AuctionSetAllocationRatio(allocationRatioConst)
require.Nil(t, err)
@ -178,8 +188,10 @@ func TestAuctionSetDonationAddress(t *testing.T) {
donationAddress, err := auctionClientTest.AuctionGetDonationAddress()
require.Nil(t, err)
assert.Equal(t, &newDonationAddress, donationAddress)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newDonationAddress, auctionEvents.NewDonationAddress[0].NewDonationAddress)
_, err = auctionClientTest.AuctionSetDonationAddress(donationAddressConst)
require.Nil(t, err)
@ -193,8 +205,10 @@ func TestAuctionSetBootCoordinator(t *testing.T) {
bootCoordinator, err := auctionClientTest.AuctionGetBootCoordinator()
require.Nil(t, err)
assert.Equal(t, &newBootCoordinator, bootCoordinator)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newBootCoordinator, auctionEvents.NewBootCoordinator[0].NewBootCoordinator)
_, err = auctionClientTest.AuctionSetBootCoordinator(bootCoordinatorAddressConst)
require.Nil(t, err)
@ -227,8 +241,10 @@ func TestAuctionChangeDefaultSlotSetBid(t *testing.T) {
minBid, err := auctionClientTest.AuctionGetDefaultSlotSetBid(set)
require.Nil(t, err)
assert.Equal(t, minBid, newInitialMinBid)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, slotSet, auctionEvents.NewDefaultSlotSetBid[0].SlotSet)
assert.Equal(t, newInitialMinBid, auctionEvents.NewDefaultSlotSetBid[0].NewInitialMinBid)
newMinBid := new(big.Int)
@ -251,8 +267,10 @@ func TestAuctionRegisterCoordinator(t *testing.T) {
_, err := auctionClientTest.AuctionSetCoordinator(forgerAddress, URL)
require.Nil(t, err)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, forgerAddress, auctionEvents.SetCoordinator[0].ForgerAddress)
assert.Equal(t, bidderAddress, auctionEvents.SetCoordinator[0].BidderAddress)
assert.Equal(t, URL, auctionEvents.SetCoordinator[0].CoordinatorURL)
@ -268,8 +286,10 @@ func TestAuctionBid(t *testing.T) {
bidderAddress := governanceAddressConst
_, err = auctionClientTest.AuctionBid(amount, currentSlot+4, bidAmount, deadline)
require.Nil(t, err)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, bidAmount, auctionEvents.NewBid[0].BidAmount)
assert.Equal(t, bidderAddress, auctionEvents.NewBid[0].Bidder)
assert.Equal(t, currentSlot+4, auctionEvents.NewBid[0].Slot)
@ -306,8 +326,10 @@ func TestAuctionMultiBid(t *testing.T) {
bidderAddress := governanceAddressConst
_, err = auctionClientTest.AuctionMultiBid(budget, currentSlot+4, currentSlot+10, slotSet, maxBid, minBid, deadline)
require.Nil(t, err)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, bidderAddress, auctionEvents.NewBid[0].Bidder)
assert.Equal(t, currentSlot+4, auctionEvents.NewBid[0].Slot)
assert.Equal(t, bidderAddress, auctionEvents.NewBid[1].Bidder)
@ -334,8 +356,10 @@ func TestAuctionClaimHEZ(t *testing.T) {
_, err := auctionClientTest.AuctionClaimHEZ()
require.Nil(t, err)
currentBlockNum, _ := auctionClientTest.client.EthLastBlock()
auctionEvents, _, _ := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
currentBlockNum, err := auctionClientTest.client.EthLastBlock()
require.Nil(t, err)
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, amount, auctionEvents.HEZClaimed[0].Amount)
assert.Equal(t, governanceAddressConst, auctionEvents.HEZClaimed[0].Owner)
}
@ -345,10 +369,12 @@ func TestAuctionForge(t *testing.T) {
require.Nil(t, err)
slotConst := 4
blockNum := int64(int(blocksPerSlot)*slotConst + int(genesisBlock))
currentBlockNum, _ := auctionClientTestHermez.client.EthLastBlock()
currentBlockNum, err := auctionClientTestHermez.client.EthLastBlock()
require.Nil(t, err)
blocksToAdd := blockNum - currentBlockNum
addBlocks(blocksToAdd, ethClientDialURL)
currentBlockNum, _ = auctionClientTestHermez.client.EthLastBlock()
currentBlockNum, err = auctionClientTestHermez.client.EthLastBlock()
require.Nil(t, err)
assert.Equal(t, currentBlockNum, blockNum)
_, err = auctionClientTestHermez.AuctionForge(governanceAddressConst)
require.Nil(t, err)

+ 100
- 51
eth/rollup_test.go

@ -77,8 +77,10 @@ func TestRollupAddToken(t *testing.T) {
require.Nil(t, err)
_, err = rollupClient.RollupAddToken(tokenHEZAddressConst, feeAddToken, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, tokenHEZAddressConst, rollupEvents.AddToken[0].TokenAddress)
assert.Equal(t, registerTokensCount, common.TokenID(rollupEvents.AddToken[0].TokenID).BigInt())
@ -106,7 +108,8 @@ func TestRollupForgeBatch(t *testing.T) {
// Add Blocks
blockNum := int64(int(blocksPerSlot)*int(currentSlot+4) + int(genesisBlock))
currentBlockNum, _ := auctionClient.client.EthLastBlock()
currentBlockNum, err := auctionClient.client.EthLastBlock()
require.Nil(t, err)
blocksToAdd := blockNum - currentBlockNum
addBlocks(blocksToAdd, ethClientDialURL)
@ -155,8 +158,10 @@ func TestRollupForgeBatch(t *testing.T) {
_, err = rollupClient.RollupForgeBatch(argsForge)
require.Nil(t, err)
currentBlockNum, _ = rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err = rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, int64(1), rollupEvents.ForgeBatch[0].BatchNum)
ethHashForge = rollupEvents.ForgeBatch[0].EthTxHash
@ -181,8 +186,10 @@ func TestRollupUpdateForgeL1L2BatchTimeout(t *testing.T) {
_, err := rollupClient.RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newForgeL1L2BatchTimeout, rollupEvents.UpdateForgeL1L2BatchTimeout[0].NewForgeL1L2BatchTimeout)
}
@ -192,8 +199,10 @@ func TestRollupUpdateFeeAddToken(t *testing.T) {
_, err := rollupClient.RollupUpdateFeeAddToken(newFeeAddToken)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newFeeAddToken, rollupEvents.UpdateFeeAddToken[0].NewFeeAddToken)
}
@ -217,8 +226,10 @@ func TestRollupL1UserTxETHCreateAccountDeposit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -245,8 +256,10 @@ func TestRollupL1UserTxERC20CreateAccountDeposit(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -273,8 +286,10 @@ func TestRollupL1UserTxERC20PermitCreateAccountDeposit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -302,8 +317,10 @@ func TestRollupL1UserTxETHDeposit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -330,8 +347,10 @@ func TestRollupL1UserTxERC20Deposit(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -358,8 +377,10 @@ func TestRollupL1UserTxERC20PermitDeposit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -387,8 +408,10 @@ func TestRollupL1UserTxETHDepositTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -415,8 +438,10 @@ func TestRollupL1UserTxERC20DepositTransfer(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -443,8 +468,10 @@ func TestRollupL1UserTxERC20PermitDepositTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -472,8 +499,10 @@ func TestRollupL1UserTxETHCreateAccountDepositTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -500,8 +529,10 @@ func TestRollupL1UserTxERC20CreateAccountDepositTransfer(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -528,8 +559,10 @@ func TestRollupL1UserTxERC20PermitCreateAccountDepositTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -557,8 +590,10 @@ func TestRollupL1UserTxETHForceTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -585,8 +620,10 @@ func TestRollupL1UserTxERC20ForceTransfer(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -613,8 +650,10 @@ func TestRollupL1UserTxERC20PermitForceTransfer(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -642,8 +681,10 @@ func TestRollupL1UserTxETHForceExit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -670,8 +711,10 @@ func TestRollupL1UserTxERC20ForceExit(t *testing.T) {
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -700,8 +743,10 @@ func TestRollupL1UserTxERC20PermitForceExit(t *testing.T) {
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ)
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx)
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount)
@ -748,8 +793,10 @@ func TestRollupForgeBatch2(t *testing.T) {
_, err = rollupClient.RollupForgeBatch(argsForge)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, int64(2), rollupEvents.ForgeBatch[0].BatchNum)
ethHashForge = rollupEvents.ForgeBatch[0].EthTxHash
@ -775,9 +822,9 @@ func TestRollupWithdrawMerkleProof(t *testing.T) {
numExitRoot := int64(2)
fromIdx := int64(256)
amount := big.NewInt(10)
// siblingBytes0, _ := new(big.Int).SetString("19508838618377323910556678335932426220272947530531646682154552299216398748115", 10)
// siblingBytes0, err := new(big.Int).SetString("19508838618377323910556678335932426220272947530531646682154552299216398748115", 10)
// require.Nil(t, err)
// siblingBytes1, _ := new(big.Int).SetString("15198806719713909654457742294233381653226080862567104272457668857208564789571", 10)
// siblingBytes1, err := new(big.Int).SetString("15198806719713909654457742294233381653226080862567104272457668857208564789571", 10)
// require.Nil(t, err)
var siblings []*big.Int
// siblings = append(siblings, siblingBytes0)
@ -787,8 +834,10 @@ func TestRollupWithdrawMerkleProof(t *testing.T) {
_, err = rollupClientAux.RollupWithdrawMerkleProof(pk, tokenID, numExitRoot, fromIdx, amount, siblings, instantWithdraw)
require.Nil(t, err)
currentBlockNum, _ := rollupClient.client.EthLastBlock()
rollupEvents, _, _ := rollupClient.RollupEventsByBlock(currentBlockNum)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.Nil(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, uint64(fromIdx), rollupEvents.Withdraw[0].Idx)
assert.Equal(t, instantWithdraw, rollupEvents.Withdraw[0].InstantWithdraw)

+ 36
- 18
eth/wdelayer_test.go

@ -41,8 +41,10 @@ func TestWDelayerSetHermezGovernanceDAOAddress(t *testing.T) {
auxAddress, err := wdelayerClientTest.WDelayerGetHermezGovernanceDAOAddress()
require.Nil(t, err)
assert.Equal(t, &auxAddressConst, auxAddress)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, auxAddressConst, wdelayerEvents.NewHermezGovernanceDAOAddress[0].NewHermezGovernanceDAOAddress)
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
require.Nil(t, err)
@ -64,8 +66,10 @@ func TestWDelayerSetHermezKeeperAddress(t *testing.T) {
auxAddress, err := wdelayerClientTest.WDelayerGetHermezKeeperAddress()
require.Nil(t, err)
assert.Equal(t, &auxAddressConst, auxAddress)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, auxAddressConst, wdelayerEvents.NewHermezKeeperAddress[0].NewHermezKeeperAddress)
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
require.Nil(t, err)
@ -87,8 +91,10 @@ func TestWDelayerSetWhiteHackGroupAddress(t *testing.T) {
auxAddress, err := wdelayerClientTest.WDelayerGetWhiteHackGroupAddress()
require.Nil(t, err)
assert.Equal(t, &auxAddressConst, auxAddress)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, auxAddressConst, wdelayerEvents.NewWhiteHackGroupAddress[0].NewWhiteHackGroupAddress)
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
require.Nil(t, err)
@ -116,8 +122,10 @@ func TestWDelayerChangeWithdrawalDelay(t *testing.T) {
withdrawalDelay, err := wdelayerClientTest.WDelayerGetWithdrawalDelay()
require.Nil(t, err)
assert.Equal(t, newWithdrawalDelay, withdrawalDelay)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, newWithdrawalDelay.Uint64(), wdelayerEvents.NewWithdrawalDelay[0].WithdrawalDelay)
}
@ -128,8 +136,10 @@ func TestWDelayerDeposit(t *testing.T) {
require.Nil(t, err)
_, err = wdelayerClientHermez.WDelayerDeposit(auxAddressConst, tokenHEZAddressConst, amount)
require.Nil(t, err)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, amount, wdelayerEvents.Deposit[0].Amount)
assert.Equal(t, auxAddressConst, wdelayerEvents.Deposit[0].Owner)
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.Deposit[0].Token)
@ -152,8 +162,10 @@ func TestWDelayerWithdrawal(t *testing.T) {
addBlock(ethClientDialURL)
_, err = wdelayerClientTest.WDelayerWithdrawal(auxAddressConst, tokenHEZAddressConst)
require.Nil(t, err)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, amount, wdelayerEvents.Withdraw[0].Amount)
assert.Equal(t, auxAddressConst, wdelayerEvents.Withdraw[0].Owner)
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.Withdraw[0].Token)
@ -166,8 +178,10 @@ func TestWDelayerSecondDeposit(t *testing.T) {
require.Nil(t, err)
_, err = wdelayerClientHermez.WDelayerDeposit(auxAddressConst, tokenHEZAddressConst, amount)
require.Nil(t, err)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, amount, wdelayerEvents.Deposit[0].Amount)
assert.Equal(t, auxAddressConst, wdelayerEvents.Deposit[0].Owner)
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.Deposit[0].Token)
@ -181,8 +195,10 @@ func TestWDelayerEnableEmergencyMode(t *testing.T) {
emergencyMode, err := wdelayerClientTest.WDelayerIsEmergencyMode()
require.Nil(t, err)
assert.Equal(t, true, emergencyMode)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
auxEvent := new(WDelayerEventEmergencyModeEnabled)
assert.Equal(t, auxEvent, &wdelayerEvents.EmergencyModeEnabled[0])
}
@ -208,8 +224,10 @@ func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
addTime(seconds, ethClientDialURL)
_, err = wdelayerClientWhite.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
require.Nil(t, err)
currentBlockNum, _ := wdelayerClientTest.client.EthLastBlock()
wdelayerEvents, _, _ := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
require.Nil(t, err)
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
require.Nil(t, err)
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Token)
assert.Equal(t, governanceAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].To)
assert.Equal(t, whiteHackGroupAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Who)

Loading…
Cancel
Save