[#770] node/config: Add proxy contract to config

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-08-24 15:59:28 +03:00 committed by Pavel Karpy
parent 13f1273e82
commit d77b2d1b76
5 changed files with 21 additions and 5 deletions

View file

@ -14,7 +14,7 @@ const (
// Netmap returns value of "netmap" config parameter
// from "contracts" section.
//
// Throws panic if value is not is not a 20-byte LE hex-encoded string.
// Throws panic if value is not a 20-byte LE hex-encoded string.
func Netmap(c *config.Config) util.Uint160 {
return contractAddress(c, "netmap")
}
@ -22,7 +22,7 @@ func Netmap(c *config.Config) util.Uint160 {
// Balance returns value of "balance" config parameter
// from "contracts" section.
//
// Throws panic if value is not is not a 20-byte LE hex-encoded string.
// Throws panic if value is not a 20-byte LE hex-encoded string.
func Balance(c *config.Config) util.Uint160 {
return contractAddress(c, "balance")
}
@ -30,7 +30,7 @@ func Balance(c *config.Config) util.Uint160 {
// Container returns value of "container" config parameter
// from "contracts" section.
//
// Throws panic if value is not is not a 20-byte LE hex-encoded string.
// Throws panic if value is not a 20-byte LE hex-encoded string.
func Container(c *config.Config) util.Uint160 {
return contractAddress(c, "container")
}
@ -38,11 +38,19 @@ func Container(c *config.Config) util.Uint160 {
// Reputation returns value of "reputation" config parameter
// from "contracts" section.
//
// Throws panic if value is not is not a 20-byte LE hex-encoded string.
// Throws panic if value is not a 20-byte LE hex-encoded string.
func Reputation(c *config.Config) util.Uint160 {
return contractAddress(c, "reputation")
}
// Proxy returns value of "proxy" config parameter
// from "contracts" section.
//
// Throws panic if value is not a 20-byte LE hex-encoded string.
func Proxy(c *config.Config) util.Uint160 {
return contractAddress(c, "proxy")
}
func contractAddress(c *config.Config, name string) util.Uint160 {
v := config.String(c.Sub(subsection), name)
if v == "" {

View file

@ -34,16 +34,21 @@ func TestContractsSection(t *testing.T) {
expReputation, err := util.Uint160DecodeStringLE("441995f631c1da2b133462b71859494a5cd45e90")
require.NoError(t, err)
expProxy, err := util.Uint160DecodeStringLE("ad7c6b55b737b696e5c82c85445040964a03e97f")
require.NoError(t, err)
var fileConfigTest = func(c *config.Config) {
balance := contractsconfig.Balance(c)
container := contractsconfig.Container(c)
netmap := contractsconfig.Netmap(c)
reputation := contractsconfig.Reputation(c)
proxy := contractsconfig.Proxy(c)
require.Equal(t, expBalance, balance)
require.Equal(t, expConatiner, container)
require.Equal(t, expNetmap, netmap)
require.Equal(t, expReputation, reputation)
require.Equal(t, expProxy, proxy)
}
configtest.ForEachFileType(path, fileConfigTest)