mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
TxSelector Coord fees & Nonces checks & other
- Add missing Fees to CoordAccounts after processing PoolL2Txs - Add Nonces checks for L2Txs (txs with incorrect nonces not included in the selection) - Add missing MakeCheckpoint() at the LocalAccountsDB once the selection is done - Add TxSelector test of full flow using Til.SetBlockchainMinimumFlow0 checking balances & parameters
This commit is contained in:
@@ -674,6 +674,15 @@ func (tc *Context) generatePoolL2Txs() ([]common.PoolL2Tx, error) {
|
||||
return txs, nil
|
||||
}
|
||||
|
||||
// RestartNonces sets all the Users.Accounts.Nonces to 0
|
||||
func (tc *Context) RestartNonces() {
|
||||
for name, user := range tc.Users {
|
||||
for tokenID := range user.Accounts {
|
||||
tc.Users[name].Accounts[tokenID].Nonce = common.Nonce(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// generateKeys generates BabyJubJub & Address keys for the given list of user
|
||||
// names in a deterministic way. This means, that for the same given
|
||||
// 'userNames' in a certain order, the keys will be always the same.
|
||||
|
||||
@@ -219,8 +219,15 @@ func TestGeneratePoolL2Txs(t *testing.T) {
|
||||
assert.Equal(t, tc.Users["User1"].BJJ.Public().String(), poolL2Txs[5].ToBJJ.String())
|
||||
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[0].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[1].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[2].Nonce)
|
||||
assert.Equal(t, common.Nonce(1), poolL2Txs[3].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[4].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[5].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[6].Nonce)
|
||||
assert.Equal(t, common.Nonce(0), poolL2Txs[7].Nonce)
|
||||
assert.Equal(t, common.Nonce(2), poolL2Txs[8].Nonce)
|
||||
assert.Equal(t, common.Nonce(3), poolL2Txs[9].Nonce)
|
||||
|
||||
assert.Equal(t, tc.Users["B"].Addr.Hex(), poolL2Txs[9].ToEthAddr.Hex())
|
||||
assert.Equal(t, common.EmptyBJJComp, poolL2Txs[9].ToBJJ)
|
||||
|
||||
Reference in New Issue
Block a user