arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/api/aux_test.go
api/aux_test.goRaw
 1package api
 2
 3import (
 4	"math/big"
 5	"strconv"
 6	"time"
 7
 8	ethCommon "github.com/ethereum/go-ethereum/common"
 9	"github.com/hermeznetwork/hermez-node/common"
10	"github.com/iden3/go-merkletree"
11)
12
13func AddAditionalInformation(blocks []common.BlockData) {
14	for i := range blocks {
15		blocks[i].Block.Timestamp = time.Now().Add(time.Second * 13).UTC()
16		blocks[i].Block.Hash = ethCommon.BigToHash(big.NewInt(blocks[i].Block.Num))
17		for j := range blocks[i].Rollup.AddedTokens {
18			blocks[i].Rollup.AddedTokens[j].Name = "NAME" + strconv.Itoa(int(blocks[i].Rollup.AddedTokens[j].TokenID))
19			blocks[i].Rollup.AddedTokens[j].Symbol = strconv.Itoa(int(blocks[i].Rollup.AddedTokens[j].TokenID))
20			blocks[i].Rollup.AddedTokens[j].Decimals = uint64(blocks[i].Rollup.AddedTokens[j].TokenID + 1)
21		}
22		for x := range blocks[i].Rollup.Batches {
23			for q := range blocks[i].Rollup.Batches[x].CreatedAccounts {
24				blocks[i].Rollup.Batches[x].CreatedAccounts[q].Balance =
25					big.NewInt(int64(blocks[i].Rollup.Batches[x].CreatedAccounts[q].Idx * 10000000))
26			}
27			for y := range blocks[i].Rollup.Batches[x].ExitTree {
28				blocks[i].Rollup.Batches[x].ExitTree[y].MerkleProof =
29					&merkletree.CircomVerifierProof{
30						Root: &merkletree.Hash{byte(y), byte(y + 1)},
31						Siblings: []*merkletree.Hash{
32							merkletree.NewHashFromBigInt(big.NewInt(int64(y) * 10)),
33							merkletree.NewHashFromBigInt(big.NewInt(int64(y)*100 + 1)),
34							merkletree.NewHashFromBigInt(big.NewInt(int64(y)*1000 + 2))},
35						OldKey:   &merkletree.Hash{byte(y * 1), byte(y*1 + 1)},
36						OldValue: &merkletree.Hash{byte(y * 2), byte(y*2 + 1)},
37						IsOld0:   y%2 == 0,
38						Key:      &merkletree.Hash{byte(y * 3), byte(y*3 + 1)},
39						Value:    &merkletree.Hash{byte(y * 4), byte(y*4 + 1)},
40						Fnc:      y % 2,
41					}
42			}
43		}
44	}
45}