From cfdea579771cbffddf24b3a367eb190f247f3e12 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Wed, 21 Oct 2020 14:59:39 +0200 Subject: [PATCH] Fix test generated transactions L1Tx type --- test/transakcio/txs.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/transakcio/txs.go b/test/transakcio/txs.go index 511c9e5..1929d94 100644 --- a/test/transakcio/txs.go +++ b/test/transakcio/txs.go @@ -270,8 +270,9 @@ func (tc *TestContext) GenerateBlocks(set string) ([]BlockData, error) { // 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 @@ func (tc *TestContext) GenerateBlocks(set string) ([]BlockData, error) { } 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 {