Test purger, fix some nonces

- Test all the purger functions
- Fix nonces set by til (previously til started with nonce 1 for pool l2txs,
  but the correct implementation is to start with nonce 0)
- Rename L2DB.CheckNonces to L2DB.invalidateOldNoncesQuery
- Rename L2DB.checkNoncesQuery to L2DB.InvalidateOldNonces

Related https://github.com/hermeznetwork/hermez-node/issues/392 (Fix checkNoncesQuery)
Resolve https://github.com/hermeznetwork/hermez-node/issues/396
This commit is contained in:
Eduard S
2020-12-21 17:36:21 +01:00
parent 8a2df8de0d
commit a8ac35059a
8 changed files with 325 additions and 49 deletions

View File

@@ -597,7 +597,6 @@ func (tc *Context) generatePoolL2Txs() ([]common.PoolL2Tx, error) {
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error()))
}
}
tc.Users[inst.From].Accounts[inst.TokenID].Nonce++
// if account of receiver does not exist, don't use
// ToIdx, and use only ToEthAddr & ToBJJ
tx := common.PoolL2Tx{
@@ -612,6 +611,7 @@ func (tc *Context) generatePoolL2Txs() ([]common.PoolL2Tx, error) {
RqToBJJ: common.EmptyBJJComp,
Type: inst.Typ,
}
tc.Users[inst.From].Accounts[inst.TokenID].Nonce++
if tx.Type == common.TxTypeTransfer {
tx.ToIdx = tc.Users[inst.To].Accounts[inst.TokenID].Idx
tx.ToEthAddr = tc.Users[inst.To].Addr
@@ -639,7 +639,6 @@ func (tc *Context) generatePoolL2Txs() ([]common.PoolL2Tx, error) {
txs = append(txs, tx)
case common.TxTypeExit:
tc.Users[inst.From].Accounts[inst.TokenID].Nonce++
tx := common.PoolL2Tx{
FromIdx: tc.Users[inst.From].Accounts[inst.TokenID].Idx,
ToIdx: common.Idx(1), // as is an Exit
@@ -650,6 +649,7 @@ func (tc *Context) generatePoolL2Txs() ([]common.PoolL2Tx, error) {
State: common.PoolL2TxStatePending,
Type: common.TxTypeExit,
}
tc.Users[inst.From].Accounts[inst.TokenID].Nonce++
nTx, err := common.NewPoolL2Tx(&tx)
if err != nil {
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error()))