Merge pull request #1274 from rlan35/validator_test

Add test for validator info
pull/1280/head
Rongjian Lan 5 years ago committed by GitHub
commit 594c940aa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      internal/genesis/foundational.go
  2. 35
      internal/genesis/genesis_test.go

@ -316,6 +316,6 @@ var FoundationalNodeAccountsV1 = []DeployAccount{
{Index: "155", Address: "one10uyfuzaztcccz97w29v0k64rzmhj4k862kfh5q", BlsPublicKey: "e75e5a222bd9e9004385d593194606f48b3e6bf8a95c68830ea1cd8f56bbcdedcb680c9598c66230ea0c2b79a6c58296"},
{Index: "156", Address: "one1s3dx73sa5dzrksmds5recptale8pxsa4d4hzt4", BlsPublicKey: "87d4f6c37073a108b94a6e7799f62b2051c44892328bdcb8e5dd4f4596b1ba2952947c744b5daf183e9f8361282c9101"},
{Index: "157", Address: "one1vfglvsfuk52025r5apqlfaqky37462tsdjeemf", BlsPublicKey: "6d320742fbff3aa1877aadb9316a865edbdecb0fb74fc973272d73ec1deaff131b653c3ab7a2b26753c717347f450a00"},
{Index: "158", Address: "one1pjn8zz5av5ddenaxmu6qrs381xuapygkeatxga", BlsPublicKey: "71c907378831009328f28db0e324848767b58e49eae1f2774e81276e25732bfea5ed8a567fed15afb010be05b9732b16"},
{Index: "158", Address: "one1pjn8zz5av5ddenaxmu6qrs38lxuapygkeatxga", BlsPublicKey: "71c907378831009328f28db0e324848767b58e49eae1f2774e81276e25732bfea5ed8a567fed15afb010be05b9732b16"},
{Index: "159", Address: "one1fzh923dkauvyye7w68nc38j2dw54gldu5mheaz", BlsPublicKey: "b5c94a5071f942c77f3599098430b8f2dbd6da70c5ef830192bdef5638908cd1fa188059d7aecc8b721116b946c4cc8e"},
}

@ -4,7 +4,12 @@ import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"testing"
"github.com/btcsuite/btcutil/bech32"
"github.com/harmony-one/bls/ffi/go/bls"
)
func TestString(t *testing.T) {
@ -43,3 +48,33 @@ func testGenesisccounts(t *testing.T) {
index++
}
}
func TestCommitteeAccounts(test *testing.T) {
testAccounts(test, FoundationalNodeAccounts)
testAccounts(test, FoundationalNodeAccountsV1)
testAccounts(test, HarmonyAccounts)
testAccounts(test, TNHarmonyAccounts)
testAccounts(test, TNFoundationalAccounts)
}
func testAccounts(test *testing.T, accounts []DeployAccount) {
index := 0
for _, account := range accounts {
accIndex, _ := strconv.Atoi(strings.Trim(account.Index, " "))
if accIndex != index {
test.Error("Account index not in sequence", account.Index)
}
index++
_, _, err := bech32.Decode(account.Address)
if err != nil {
test.Error("Account address is not valid bech32 address", err)
}
pubKey := bls.PublicKey{}
err = pubKey.DeserializeHexStr(account.BlsPublicKey)
if err != nil {
test.Error("Account bls public key is not valid", err)
}
}
}

Loading…
Cancel
Save