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(chainID uint16) Config {
13 var config Config
14
15 var rollupPublicConstants common.RollupConstants
16 rollupPublicConstants.AbsoluteMaxL1L2BatchTimeout = 240
17 rollupPublicConstants.HermezAuctionContract = ethCommon.HexToAddress("0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e")
18 rollupPublicConstants.HermezGovernanceAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
19 rollupPublicConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
20 rollupPublicConstants.WithdrawDelayerContract = ethCommon.HexToAddress("0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe")
21 var verifier common.RollupVerifierStruct
22 verifier.MaxTx = 512
23 verifier.NLevels = 32
24 rollupPublicConstants.Verifiers = append(rollupPublicConstants.Verifiers, verifier)
25
26 var auctionConstants common.AuctionConstants
27 auctionConstants.BlocksPerSlot = 40
28 auctionConstants.GenesisBlockNum = 100
29 auctionConstants.GovernanceAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
30 auctionConstants.InitialMinimalBidding, _ = new(big.Int).SetString("10000000000000000000", 10)
31 auctionConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
32 auctionConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
33
34 var wdelayerConstants common.WDelayerConstants
35 wdelayerConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
36 wdelayerConstants.MaxEmergencyModeTime = uint64(1000000)
37 wdelayerConstants.MaxWithdrawalDelay = uint64(10000000)
38
39 config.RollupConstants = rollupPublicConstants
40 config.AuctionConstants = auctionConstants
41 config.WDelayerConstants = wdelayerConstants
42
43 config.ChainID = chainID
44 config.HermezAddress = ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6")
45
46 return config
47}
48
49func TestGetConfig(t *testing.T) {
50 endpoint := apiURL + "config"
51 var configTest configAPI
52 assert.NoError(t, doGoodReq("GET", endpoint, nil, &configTest))
53 assert.Equal(t, config, configTest)
54 assert.Equal(t, api.cg, &configTest)
55}