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() 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	return config
44}
45
46func TestGetConfig(t *testing.T) {
47	endpoint := apiURL + "config"
48	var configTest configAPI
49	assert.NoError(t, doGoodReq("GET", endpoint, nil, &configTest))
50	assert.Equal(t, config, configTest)
51	assert.Equal(t, api.cg, &configTest)
52}