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