arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/api/config_test.go
api/config_test.goRaw
 1package api
 2
 3import (
 4	"math/big"
 5	"testing"
 6
 7	ethCommon "github.com/ethereum/go-ethereum/common"
 8	"github.com/hermeznetwork/hermez-node/common"
 9	"github.com/stretchr/testify/assert"
10)
11
12func getConfigTest() configAPI {
13	var config configAPI
14
15	config.RollupConstants.ExchangeMultiplier = common.RollupConstExchangeMultiplier
16	config.RollupConstants.ExitIdx = common.RollupConstExitIDx
17	config.RollupConstants.ReservedIdx = common.RollupConstReservedIDx
18	config.RollupConstants.LimitLoadAmount, _ = new(big.Int).SetString("340282366920938463463374607431768211456", 10)
19	config.RollupConstants.LimitL2TransferAmount, _ = new(big.Int).SetString("6277101735386680763835789423207666416102355444464034512896", 10)
20	config.RollupConstants.LimitTokens = common.RollupConstLimitTokens
21	config.RollupConstants.L1CoordinatorTotalBytes = common.RollupConstL1CoordinatorTotalBytes
22	config.RollupConstants.L1UserTotalBytes = common.RollupConstL1UserTotalBytes
23	config.RollupConstants.MaxL1UserTx = common.RollupConstMaxL1UserTx
24	config.RollupConstants.MaxL1Tx = common.RollupConstMaxL1Tx
25	config.RollupConstants.InputSHAConstantBytes = common.RollupConstInputSHAConstantBytes
26	config.RollupConstants.NumBuckets = common.RollupConstNumBuckets
27	config.RollupConstants.MaxWithdrawalDelay = common.RollupConstMaxWithdrawalDelay
28	var rollupPublicConstants common.RollupConstants
29	rollupPublicConstants.AbsoluteMaxL1L2BatchTimeout = 240
30	rollupPublicConstants.HermezAuctionContract = ethCommon.HexToAddress("0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e")
31	rollupPublicConstants.HermezGovernanceDAOAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
32	rollupPublicConstants.SafetyAddress = ethCommon.HexToAddress("0xE5904695748fe4A84b40b3fc79De2277660BD1D3")
33	rollupPublicConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
34	rollupPublicConstants.WithdrawDelayerContract = ethCommon.HexToAddress("0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe")
35	var verifier common.RollupVerifierStruct
36	verifier.MaxTx = 512
37	verifier.NLevels = 32
38	rollupPublicConstants.Verifiers = append(rollupPublicConstants.Verifiers, verifier)
39
40	var auctionConstants common.AuctionConstants
41	auctionConstants.BlocksPerSlot = 40
42	auctionConstants.GenesisBlockNum = 100
43	auctionConstants.GovernanceAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
44	auctionConstants.InitialMinimalBidding, _ = new(big.Int).SetString("10000000000000000000", 10)
45	auctionConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
46	auctionConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
47
48	var wdelayerConstants common.WDelayerConstants
49	wdelayerConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
50	wdelayerConstants.MaxEmergencyModeTime = uint64(1000000)
51	wdelayerConstants.MaxWithdrawalDelay = uint64(10000000)
52
53	config.RollupConstants.PublicConstants = rollupPublicConstants
54	config.AuctionConstants = auctionConstants
55	config.WDelayerConstants = wdelayerConstants
56
57	return config
58}
59
60func TestGetConfig(t *testing.T) {
61	endpoint := apiURL + "config"
62	var configTest configAPI
63	assert.NoError(t, doGoodReq("GET", endpoint, nil, &configTest))
64	assert.Equal(t, config, configTest)
65	assert.Equal(t, cg, &configTest)
66}