arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Fix test generated transactions L1Tx type
arnaucube root@arnaucube.com
Wed, 21 Oct 2020 14:59:39 +0200
commit

cfdea579771cbffddf24b3a367eb190f247f3e12

parent

4ca2124cf96a39cc698865e177ab2b59e97a50e0

1 files changed, 14 insertions(+), 2 deletions(-)

jump to
M test/transakcio/txs.go → test/transakcio/txs.go

@@ -270,8 +270,9 @@

// once Idxs are calculated, update transactions to use the new Idxs for i := 0; i < len(tc.queues[tc.toForgeNum]); i++ { testTx := &tc.queues[tc.toForgeNum][i] - // set real Idx - testTx.L1Tx.FromIdx = tc.Users[testTx.fromIdxName].Accounts[testTx.L1Tx.TokenID].Idx + if testTx.L1Tx.Type != common.TxTypeCreateAccountDeposit && testTx.L1Tx.Type != common.TxTypeCreateAccountDepositTransfer { + testTx.L1Tx.FromIdx = tc.Users[testTx.fromIdxName].Accounts[testTx.L1Tx.TokenID].Idx + } testTx.L1Tx.FromEthAddr = tc.Users[testTx.fromIdxName].Addr testTx.L1Tx.FromBJJ = tc.Users[testTx.fromIdxName].BJJ.Public() if testTx.toIdxName == "" {

@@ -279,6 +280,17 @@ testTx.L1Tx.ToIdx = common.Idx(0)

} else { testTx.L1Tx.ToIdx = tc.Users[testTx.toIdxName].Accounts[testTx.L1Tx.TokenID].Idx } + if testTx.L1Tx.Type == common.TxTypeExit { + testTx.L1Tx.ToIdx = common.Idx(1) + } + bn := common.BatchNum(tc.currBatchNum) + testTx.L1Tx.BatchNum = &bn + nTx, err := common.NewL1Tx(&testTx.L1Tx) + if err != nil { + return nil, fmt.Errorf("Line %d: %s", testTx.lineNum, err.Error()) + } + testTx.L1Tx = *nTx + tc.currBlock.L1UserTxs = append(tc.currBlock.L1UserTxs, testTx.L1Tx) } if err = tc.setIdxs(); err != nil {