mirror of
https://github.com/luxfi/indexer.git
synced 2026-09-24 00:25:37 +00:00
Co-authored-by: dhrubabasu <[email protected]> Co-authored-by: Patrick O'Grady <[email protected]> Co-authored-by: Stephen <[email protected]>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package params
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ava-labs/avalanchego/ids"
|
|
"github.com/ava-labs/avalanchego/utils/hashing"
|
|
)
|
|
|
|
func TestForValueChainID(t *testing.T) {
|
|
res := ForValueChainID(nil, nil)
|
|
if res != nil {
|
|
t.Error("ForValueChainID failed")
|
|
}
|
|
tempChain := ids.ID(hashing.ComputeHash256Array([]byte("tid1")))
|
|
res = ForValueChainID(&tempChain, nil)
|
|
if len(res) != 1 || res[0] != tempChain.String() {
|
|
t.Error("ForValueChainID failed")
|
|
}
|
|
res = ForValueChainID(&tempChain, []string{})
|
|
if len(res) != 1 || res[0] != tempChain.String() {
|
|
t.Error("ForValueChainID failed")
|
|
}
|
|
res = ForValueChainID(&tempChain, []string{tempChain.String()})
|
|
if len(res) != 1 || res[0] != tempChain.String() {
|
|
t.Error("ForValueChainID failed")
|
|
}
|
|
tempChain2 := ids.ID(hashing.ComputeHash256Array([]byte("tid2")))
|
|
if tempChain.String() == tempChain2.String() {
|
|
t.Error("toId failed")
|
|
}
|
|
res = ForValueChainID(&tempChain, []string{tempChain2.String()})
|
|
if len(res) != 2 || res[0] != tempChain.String() || res[1] != tempChain2.String() {
|
|
t.Error("ForValueChainID failed")
|
|
}
|
|
}
|