|
|
|
@ -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) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|