2022-06-08 19:34:09 +00:00
|
|
|
package native_test
|
2020-12-13 15:26:35 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-06-08 12:17:40 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/internal/basicchain"
|
2022-03-10 14:12:04 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/neotest/chain"
|
2020-12-15 10:53:35 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-12-13 15:26:35 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-07-23 12:52:30 +00:00
|
|
|
func TestManagement_GetNEP17Contracts(t *testing.T) {
|
|
|
|
t.Run("empty chain", func(t *testing.T) {
|
2022-03-10 14:12:04 +00:00
|
|
|
bc, validators, committee := chain.NewMulti(t)
|
|
|
|
e := neotest.NewExecutor(t, bc, validators, committee)
|
|
|
|
|
|
|
|
require.ElementsMatch(t, []util.Uint160{e.NativeHash(t, nativenames.Neo),
|
|
|
|
e.NativeHash(t, nativenames.Gas)}, bc.GetNEP17Contracts())
|
2021-07-23 12:52:30 +00:00
|
|
|
})
|
|
|
|
|
2022-03-10 14:12:04 +00:00
|
|
|
t.Run("basic chain", func(t *testing.T) {
|
|
|
|
bc, validators, committee := chain.NewMultiWithCustomConfig(t, func(c *config.ProtocolConfiguration) {
|
2022-06-08 12:17:40 +00:00
|
|
|
c.P2PSigExtensions = true // `basicchain.Init` requires Notary enabled
|
2022-03-10 14:12:04 +00:00
|
|
|
})
|
|
|
|
e := neotest.NewExecutor(t, bc, validators, committee)
|
2022-06-08 19:34:09 +00:00
|
|
|
basicchain.Init(t, "../../../", e)
|
2022-03-10 14:12:04 +00:00
|
|
|
|
|
|
|
require.ElementsMatch(t, []util.Uint160{e.NativeHash(t, nativenames.Neo),
|
|
|
|
e.NativeHash(t, nativenames.Gas), e.ContractHash(t, 1)}, bc.GetNEP17Contracts())
|
2021-07-23 12:52:30 +00:00
|
|
|
})
|
|
|
|
}
|