[#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)

View file

@ -39,6 +39,7 @@ NEOFS_CONTRACTS_BALANCE=5263abba1abedbf79bb57f3e40b50b4425d2d6cd
NEOFS_CONTRACTS_CONTAINER=5d084790d7aa36cea7b53fe897380dab11d2cd3c
NEOFS_CONTRACTS_NETMAP=0cce9e948dca43a6b592efe59ddb4ecb89bdd9ca
NEOFS_CONTRACTS_REPUTATION=441995f631c1da2b133462b71859494a5cd45e90
NEOFS_CONTRACTS_PROXY=ad7c6b55b737b696e5c82c85445040964a03e97f
# Morph chain section
NEOFS_MORPH_DIAL_TIMEOUT=30s

View file

@ -57,7 +57,8 @@
"balance": "5263abba1abedbf79bb57f3e40b50b4425d2d6cd",
"container": "5d084790d7aa36cea7b53fe897380dab11d2cd3c",
"netmap": "0cce9e948dca43a6b592efe59ddb4ecb89bdd9ca",
"reputation": "441995f631c1da2b133462b71859494a5cd45e90"
"reputation": "441995f631c1da2b133462b71859494a5cd45e90",
"proxy": "ad7c6b55b737b696e5c82c85445040964a03e97f"
},
"morph": {
"dial_timeout": "30s",

View file

@ -50,6 +50,7 @@ contracts:
container: 5d084790d7aa36cea7b53fe897380dab11d2cd3c
netmap: 0cce9e948dca43a6b592efe59ddb4ecb89bdd9ca
reputation: 441995f631c1da2b133462b71859494a5cd45e90
proxy: ad7c6b55b737b696e5c82c85445040964a03e97f
morph:
dial_timeout: 30s