|
|
@ -57,7 +57,7 @@ func genKeysBjj(i int64) *keys { |
|
|
|
|
|
|
|
func TestRollupConstants(t *testing.T) { |
|
|
|
rollupConstants, err := rollupClient.RollupConstants() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, absoluteMaxL1L2BatchTimeout, rollupConstants.AbsoluteMaxL1L2BatchTimeout) |
|
|
|
assert.Equal(t, auctionAddressConst, rollupConstants.HermezAuctionContract) |
|
|
|
assert.Equal(t, tokenHEZAddressConst, rollupConstants.TokenHEZ) |
|
|
@ -69,7 +69,7 @@ func TestRollupConstants(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupRegisterTokensCount(t *testing.T) { |
|
|
|
registerTokensCount, err := rollupClient.RollupRegisterTokensCount() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, big.NewInt(1), registerTokensCount) |
|
|
|
} |
|
|
|
|
|
|
@ -77,13 +77,13 @@ func TestRollupAddToken(t *testing.T) { |
|
|
|
feeAddToken := big.NewInt(10) |
|
|
|
// Addtoken ERC20Permit
|
|
|
|
registerTokensCount, err := rollupClient.RollupRegisterTokensCount() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
_, err = rollupClient.RollupAddToken(tokenHEZAddressConst, feeAddToken, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, tokenHEZAddressConst, rollupEvents.AddToken[0].TokenAddress) |
|
|
|
assert.Equal(t, registerTokensCount, common.TokenID(rollupEvents.AddToken[0].TokenID).BigInt()) |
|
|
@ -95,11 +95,11 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
// Register Coordinator
|
|
|
|
forgerAddress := governanceAddressConst |
|
|
|
_, err := auctionClient.AuctionSetCoordinator(forgerAddress, URL) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
// MultiBid
|
|
|
|
currentSlot, err := auctionClient.AuctionGetCurrentSlotNumber() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
slotSet := [6]bool{true, false, true, false, true, false} |
|
|
|
maxBid := new(big.Int) |
|
|
|
maxBid.SetString("15000000000000000000", 10) |
|
|
@ -108,12 +108,12 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
budget := new(big.Int) |
|
|
|
budget.SetString("45200000000000000000", 10) |
|
|
|
_, err = auctionClient.AuctionMultiBid(budget, currentSlot+4, currentSlot+10, slotSet, maxBid, minBid, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
// Add Blocks
|
|
|
|
blockNum := int64(int(blocksPerSlot)*int(currentSlot+4) + int(genesisBlock)) |
|
|
|
currentBlockNum, err := auctionClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
blocksToAdd := blockNum - currentBlockNum |
|
|
|
addBlocks(blocksToAdd, ethClientDialURL) |
|
|
|
|
|
|
@ -121,7 +121,7 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
args := new(RollupForgeBatchArgs) |
|
|
|
args.FeeIdxCoordinator = []common.Idx{} // When encoded, 64 times the 0 idx means that no idx to collect fees is specified.
|
|
|
|
l1CoordinatorBytes, err := hex.DecodeString("1c660323607bb113e586183609964a333d07ebe4bef3be82ec13af453bae9590bd7711cdb6abf42f176eadfbe5506fbef5e092e5543733f91b0061d9a7747fa10694a915a6470fa230de387b51e6f4db0b09787867778687b55197ad6d6a86eac000000001") |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
numTxsL1 := len(l1CoordinatorBytes) / common.L1CoordinatorTxBytesLen |
|
|
|
for i := 0; i < numTxsL1; i++ { |
|
|
|
bytesL1Coordinator := l1CoordinatorBytes[i*common.L1CoordinatorTxBytesLen : (i+1)*common.L1CoordinatorTxBytesLen] |
|
|
@ -133,7 +133,7 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
signature = append(signature, s[:]...) |
|
|
|
signature = append(signature, v) |
|
|
|
l1Tx, err := common.L1CoordinatorTxFromBytes(bytesL1Coordinator, chainid, rollupClient.address) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
args.L1CoordinatorTxs = append(args.L1CoordinatorTxs, *l1Tx) |
|
|
|
args.L1CoordinatorTxsAuths = append(args.L1CoordinatorTxsAuths, signature) |
|
|
|
} |
|
|
@ -143,7 +143,7 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
newStateRoot.SetString("18317824016047294649053625209337295956588174734569560016974612130063629505228", 10) |
|
|
|
newExitRoot := new(big.Int) |
|
|
|
bytesNumExitRoot, err := hex.DecodeString("10a89d5fe8d488eda1ba371d633515739933c706c210c604f5bd209180daa43b") |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
newExitRoot.SetBytes(bytesNumExitRoot) |
|
|
|
args.NewLastIdx = int64(300) |
|
|
|
args.NewStRoot = newStateRoot |
|
|
@ -161,12 +161,12 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
|
|
|
|
argsForge = args |
|
|
|
_, err = rollupClient.RollupForgeBatch(argsForge) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err = rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, int64(1), rollupEvents.ForgeBatch[0].BatchNum) |
|
|
|
assert.Equal(t, uint16(len(L1UserTxs)), rollupEvents.ForgeBatch[0].L1UserTxsLen) |
|
|
@ -175,7 +175,7 @@ func TestRollupForgeBatch(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupForgeBatchArgs(t *testing.T) { |
|
|
|
args, sender, err := rollupClient.RollupForgeBatchArgs(ethHashForge, uint16(len(L1UserTxs))) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, *sender, rollupClient.client.account.Address) |
|
|
|
assert.Equal(t, argsForge.FeeIdxCoordinator, args.FeeIdxCoordinator) |
|
|
|
assert.Equal(t, argsForge.L1Batch, args.L1Batch) |
|
|
@ -190,12 +190,12 @@ func TestRollupForgeBatchArgs(t *testing.T) { |
|
|
|
func TestRollupUpdateForgeL1L2BatchTimeout(t *testing.T) { |
|
|
|
newForgeL1L2BatchTimeout := int64(222) |
|
|
|
_, err := rollupClient.RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, newForgeL1L2BatchTimeout, rollupEvents.UpdateForgeL1L2BatchTimeout[0].NewForgeL1L2BatchTimeout) |
|
|
|
} |
|
|
@ -203,49 +203,43 @@ func TestRollupUpdateForgeL1L2BatchTimeout(t *testing.T) { |
|
|
|
func TestRollupUpdateFeeAddToken(t *testing.T) { |
|
|
|
newFeeAddToken := big.NewInt(12) |
|
|
|
_, err := rollupClient.RollupUpdateFeeAddToken(newFeeAddToken) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, newFeeAddToken, rollupEvents.UpdateFeeAddToken[0].NewFeeAddToken) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupUpdateBucketsParameters(t *testing.T) { |
|
|
|
var bucketsParameters [common.RollupConstNumBuckets][4]*big.Int |
|
|
|
var bucketsParameters [common.RollupConstNumBuckets]RollupUpdateBucketsParameters |
|
|
|
for i := range bucketsParameters { |
|
|
|
bucketsParameters[i][0] = big.NewInt(int64((i + 1) * 100)) // ceilUSD
|
|
|
|
bucketsParameters[i][1] = big.NewInt(int64(i + 1)) // withdrawals
|
|
|
|
bucketsParameters[i][2] = big.NewInt(int64(i+1) * 100) // blockWithdrawalRate
|
|
|
|
bucketsParameters[i][3] = big.NewInt(int64(100000000000)) // maxWithdrawals
|
|
|
|
bucketsParameters[i].CeilUSD = big.NewInt(int64((i + 1) * 100)) |
|
|
|
bucketsParameters[i].Withdrawals = big.NewInt(int64(i + 1)) |
|
|
|
bucketsParameters[i].BlockWithdrawalRate = big.NewInt(int64(i+1) * 100) |
|
|
|
bucketsParameters[i].MaxWithdrawals = big.NewInt(int64(100000000000)) |
|
|
|
} |
|
|
|
_, err := rollupClient.RollupUpdateBucketsParameters(bucketsParameters) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
blockStampBucket = currentBlockNum |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
for i := range bucketsParameters { |
|
|
|
assert.Equal(t, bucketsParameters[i][0].String(), rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i][0].String()) |
|
|
|
assert.Equal(t, bucketsParameters[i][1].String(), rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i][1].String()) |
|
|
|
assert.Equal(t, bucketsParameters[i][2].String(), rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i][2].String()) |
|
|
|
assert.Equal(t, bucketsParameters[i][3].String(), rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i][3].String()) |
|
|
|
} |
|
|
|
|
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, bucketsParameters, rollupEvents.UpdateBucketsParameters[0].ArrayBuckets) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupUpdateWithdrawalDelay(t *testing.T) { |
|
|
|
newWithdrawalDelay := uint64(100000) |
|
|
|
newWithdrawalDelay := int64(100000) |
|
|
|
_, err := rollupClient.RollupUpdateWithdrawalDelay(newWithdrawalDelay) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
assert.Equal(t, newWithdrawalDelay, rollupEvents.UpdateWithdrawalDelay[0].NewWithdrawalDelay) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, newWithdrawalDelay, int64(rollupEvents.UpdateWithdrawalDelay[0].NewWithdrawalDelay)) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupUpdateTokenExchange(t *testing.T) { |
|
|
@ -255,20 +249,20 @@ func TestRollupUpdateTokenExchange(t *testing.T) { |
|
|
|
addressArray = append(addressArray, addressToken1) |
|
|
|
tokenPrice := 10 |
|
|
|
valueArray = append(valueArray, uint64(tokenPrice*1e14)) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
_, err = rollupClient.RollupUpdateTokenExchange(addressArray, valueArray) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, addressArray, rollupEvents.UpdateTokenExchange[0].AddressArray) |
|
|
|
assert.Equal(t, valueArray, rollupEvents.UpdateTokenExchange[0].ValueArray) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHCreateAccountDeposit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
key := genKeysBjj(2) |
|
|
|
fromIdxInt64 := int64(0) |
|
|
|
toIdxInt64 := int64(0) |
|
|
@ -285,12 +279,12 @@ func TestRollupL1UserTxETHCreateAccountDeposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(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) |
|
|
@ -301,7 +295,7 @@ func TestRollupL1UserTxETHCreateAccountDeposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20CreateAccountDeposit(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
key := genKeysBjj(1) |
|
|
|
fromIdxInt64 := int64(0) |
|
|
|
toIdxInt64 := int64(0) |
|
|
@ -317,12 +311,12 @@ func TestRollupL1UserTxERC20CreateAccountDeposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(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) |
|
|
@ -333,7 +327,7 @@ func TestRollupL1UserTxERC20CreateAccountDeposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitCreateAccountDeposit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
key := genKeysBjj(3) |
|
|
|
fromIdxInt64 := int64(0) |
|
|
|
toIdxInt64 := int64(0) |
|
|
@ -349,12 +343,12 @@ func TestRollupL1UserTxERC20PermitCreateAccountDeposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(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) |
|
|
@ -365,7 +359,7 @@ func TestRollupL1UserTxERC20PermitCreateAccountDeposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHDeposit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(256) |
|
|
|
toIdxInt64 := int64(0) |
|
|
|
tokenIDUint32 := uint32(0) |
|
|
@ -381,12 +375,12 @@ func TestRollupL1UserTxETHDeposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -396,7 +390,7 @@ func TestRollupL1UserTxETHDeposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20Deposit(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(257) |
|
|
|
toIdxInt64 := int64(0) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -411,12 +405,12 @@ func TestRollupL1UserTxERC20Deposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -426,7 +420,7 @@ func TestRollupL1UserTxERC20Deposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitDeposit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(258) |
|
|
|
toIdxInt64 := int64(0) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -440,12 +434,12 @@ func TestRollupL1UserTxERC20PermitDeposit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -455,7 +449,7 @@ func TestRollupL1UserTxERC20PermitDeposit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHDepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(256) |
|
|
|
toIdxInt64 := int64(257) |
|
|
|
tokenIDUint32 := uint32(0) |
|
|
@ -471,12 +465,12 @@ func TestRollupL1UserTxETHDepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -486,7 +480,7 @@ func TestRollupL1UserTxETHDepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20DepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(257) |
|
|
|
toIdxInt64 := int64(258) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -501,12 +495,12 @@ func TestRollupL1UserTxERC20DepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -516,7 +510,7 @@ func TestRollupL1UserTxERC20DepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitDepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(258) |
|
|
|
toIdxInt64 := int64(259) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -531,12 +525,12 @@ func TestRollupL1UserTxERC20PermitDepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -546,7 +540,7 @@ func TestRollupL1UserTxERC20PermitDepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(256) |
|
|
|
toIdxInt64 := int64(257) |
|
|
|
tokenIDUint32 := uint32(0) |
|
|
@ -562,12 +556,12 @@ func TestRollupL1UserTxETHCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -577,7 +571,7 @@ func TestRollupL1UserTxETHCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20CreateAccountDepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(257) |
|
|
|
toIdxInt64 := int64(258) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -592,12 +586,12 @@ func TestRollupL1UserTxERC20CreateAccountDepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -607,7 +601,7 @@ func TestRollupL1UserTxERC20CreateAccountDepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(258) |
|
|
|
toIdxInt64 := int64(259) |
|
|
|
loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) |
|
|
@ -622,12 +616,12 @@ func TestRollupL1UserTxERC20PermitCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -637,7 +631,7 @@ func TestRollupL1UserTxERC20PermitCreateAccountDepositTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHForceTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(256) |
|
|
|
toIdxInt64 := int64(257) |
|
|
|
tokenIDUint32 := uint32(0) |
|
|
@ -652,12 +646,12 @@ func TestRollupL1UserTxETHForceTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -667,7 +661,7 @@ func TestRollupL1UserTxETHForceTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20ForceTransfer(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(257) |
|
|
|
toIdxInt64 := int64(258) |
|
|
|
amount, _ := new(big.Int).SetString("10000000000000000000", 10) |
|
|
@ -681,12 +675,12 @@ func TestRollupL1UserTxERC20ForceTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -696,7 +690,7 @@ func TestRollupL1UserTxERC20ForceTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitForceTransfer(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(259) |
|
|
|
toIdxInt64 := int64(260) |
|
|
|
amount, _ := new(big.Int).SetString("30000000000000000000", 10) |
|
|
@ -710,12 +704,12 @@ func TestRollupL1UserTxERC20PermitForceTransfer(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -725,7 +719,7 @@ func TestRollupL1UserTxERC20PermitForceTransfer(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxETHForceExit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(256) |
|
|
|
toIdxInt64 := int64(1) |
|
|
|
tokenIDUint32 := uint32(0) |
|
|
@ -740,12 +734,12 @@ func TestRollupL1UserTxETHForceExit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -755,7 +749,7 @@ func TestRollupL1UserTxETHForceExit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20ForceExit(t *testing.T) { |
|
|
|
rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(257) |
|
|
|
toIdxInt64 := int64(1) |
|
|
|
amount, _ := new(big.Int).SetString("20000000000000000000", 10) |
|
|
@ -769,12 +763,12 @@ func TestRollupL1UserTxERC20ForceExit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -784,7 +778,7 @@ func TestRollupL1UserTxERC20ForceExit(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupL1UserTxERC20PermitForceExit(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
fromIdxInt64 := int64(258) |
|
|
|
toIdxInt64 := int64(1) |
|
|
|
fromIdx := new(common.Idx) |
|
|
@ -800,12 +794,12 @@ func TestRollupL1UserTxERC20PermitForceExit(t *testing.T) { |
|
|
|
L1UserTxs = append(L1UserTxs, l1Tx) |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) |
|
|
|
assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) |
|
|
|
assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) |
|
|
@ -816,11 +810,11 @@ func TestRollupL1UserTxERC20PermitForceExit(t *testing.T) { |
|
|
|
func TestRollupForgeBatch2(t *testing.T) { |
|
|
|
// Forge Batch 2
|
|
|
|
_, err := rollupClient.RollupForgeBatch(argsForge) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, int64(2), rollupEvents.ForgeBatch[0].BatchNum) |
|
|
|
|
|
|
@ -833,9 +827,9 @@ func TestRollupForgeBatch2(t *testing.T) { |
|
|
|
l1UserTx := L1UserTxs[i] |
|
|
|
l1UserTx.EffectiveAmount = l1UserTx.Amount |
|
|
|
l1Bytes, err := l1UserTx.BytesDataAvailability(uint32(nLevels)) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
l1UserTxDataAvailability, err := common.L1TxFromDataAvailability(l1Bytes, uint32(nLevels)) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
args.L1UserTxs = append(args.L1UserTxs, *l1UserTxDataAvailability) |
|
|
|
} |
|
|
|
newStateRoot := new(big.Int) |
|
|
@ -869,22 +863,21 @@ func TestRollupForgeBatch2(t *testing.T) { |
|
|
|
argsForge = args |
|
|
|
|
|
|
|
_, err = rollupClient.RollupForgeBatch(argsForge) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err = rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err = rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, int64(3), rollupEvents.ForgeBatch[0].BatchNum) |
|
|
|
assert.Equal(t, uint16(len(L1UserTxs)), rollupEvents.ForgeBatch[0].L1UserTxsLen) |
|
|
|
ethHashForge = rollupEvents.ForgeBatch[0].EthTxHash |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupForgeBatchArgs2(t *testing.T) { |
|
|
|
args, sender, err := rollupClient.RollupForgeBatchArgs(ethHashForge, uint16(len(L1UserTxs))) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
assert.Equal(t, *sender, rollupClient.client.account.Address) |
|
|
|
assert.Equal(t, argsForge.FeeIdxCoordinator, args.FeeIdxCoordinator) |
|
|
|
assert.Equal(t, argsForge.L1Batch, args.L1Batch) |
|
|
@ -899,38 +892,38 @@ func TestRollupForgeBatchArgs2(t *testing.T) { |
|
|
|
|
|
|
|
func TestRollupWithdrawMerkleProof(t *testing.T) { |
|
|
|
rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
var pkComp babyjub.PublicKeyComp |
|
|
|
pkCompBE, err := hex.DecodeString("adc3b754f8da621967b073a787bef8eec7052f2ba712b23af57d98f65beea8b2") |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
pkCompLE := common.SwapEndianness(pkCompBE) |
|
|
|
copy(pkComp[:], pkCompLE) |
|
|
|
|
|
|
|
pk, err := pkComp.Decompress() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
tokenID := uint32(tokenHEZID) |
|
|
|
numExitRoot := int64(3) |
|
|
|
fromIdx := int64(256) |
|
|
|
amount, _ := new(big.Int).SetString("20000000000000000000", 10) |
|
|
|
// siblingBytes0, err := new(big.Int).SetString("19508838618377323910556678335932426220272947530531646682154552299216398748115", 10)
|
|
|
|
// require.Nil(t, err)
|
|
|
|
// require.NoError(t, err)
|
|
|
|
// siblingBytes1, err := new(big.Int).SetString("15198806719713909654457742294233381653226080862567104272457668857208564789571", 10)
|
|
|
|
// require.Nil(t, err)
|
|
|
|
// require.NoError(t, err)
|
|
|
|
var siblings []*big.Int |
|
|
|
// siblings = append(siblings, siblingBytes0)
|
|
|
|
// siblings = append(siblings, siblingBytes1)
|
|
|
|
instantWithdraw := true |
|
|
|
|
|
|
|
_, err = rollupClientAux.RollupWithdrawMerkleProof(pk, tokenID, numExitRoot, fromIdx, amount, siblings, instantWithdraw) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
assert.Equal(t, uint64(fromIdx), rollupEvents.Withdraw[0].Idx) |
|
|
|
assert.Equal(t, instantWithdraw, rollupEvents.Withdraw[0].InstantWithdraw) |
|
|
@ -941,19 +934,19 @@ func TestRollupWithdrawMerkleProof(t *testing.T) { |
|
|
|
// Bucket 1
|
|
|
|
// Bucket[0].withdrawals = 1, Bucket[1].withdrawals = 2, ...
|
|
|
|
// Bucket[1].withdrawals - 1 = 1
|
|
|
|
assert.Equal(t, uint8(1), rollupEvents.UpdateBucketWithdraw[0].NumBucket) |
|
|
|
assert.Equal(t, big.NewInt(blockStampBucket), rollupEvents.UpdateBucketWithdraw[0].BlockStamp) |
|
|
|
assert.Equal(t, 1, rollupEvents.UpdateBucketWithdraw[0].NumBucket) |
|
|
|
assert.Equal(t, blockStampBucket, rollupEvents.UpdateBucketWithdraw[0].BlockStamp) |
|
|
|
assert.Equal(t, big.NewInt(1), rollupEvents.UpdateBucketWithdraw[0].Withdrawals) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRollupSafeMode(t *testing.T) { |
|
|
|
_, err := rollupClient.RollupSafeMode() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
currentBlockNum, err := rollupClient.client.EthLastBlock() |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) |
|
|
|
require.Nil(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
auxEvent := new(RollupEventSafeMode) |
|
|
|
assert.Equal(t, auxEvent, &rollupEvents.SafeMode[0]) |
|
|
|
} |