Skip to content

Commit

Permalink
update DID testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Honglei-Cong committed Dec 2, 2019
1 parent 16c4117 commit 97f6183
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion account/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func VerifyID(id string) bool {
if len(id) < 9 {
return false
}
if id[0:8] != "did:ont:" {
if id[0:8] != "did:dna:" {
return false
}
buf, err := base58.BitcoinEncoding.Decode([]byte(id[8:]))
Expand Down
6 changes: 3 additions & 3 deletions account/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"
)

var id = "did:ont:TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vT"
var id = "did:dna:TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vT"

func TestCreate(t *testing.T) {
nonce, _ := hex.DecodeString("4c6b58adc6b8c6774eee0eb07dac4e198df87aae28f8932db3982edf3ff026e4")
Expand All @@ -47,11 +47,11 @@ func TestVerify(t *testing.T) {
}

invalid := []string{
"did:ont:",
"did:dna:",
"did:else:TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vT",
"TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vT",
"did:else:TSS6S4Xhzt5wtvRBTm4y3QCT",
"did:ont:TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vt",
"did:dna:TSS6S4Xhzt5wtvRBTm4y3QCTRqB4BnU7vt",
}

for _, v := range invalid {
Expand Down
14 changes: 7 additions & 7 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ var PolarisConfig = &GenesisConfig{
HashMsgDelay: 10000,
PeerHandshakeTimeout: 10,
MaxBlockChangeView: 3000,
AdminOntID: "did:ont:AMAx993nE6NEqZjwBssUfopxnnvTdob9ij",
AdminOntID: "did:dna:AMAx993nE6NEqZjwBssUfopxnnvTdob9ij",
MinInitStake: 10000,
VrfValue: "1c9810aa9822e511d5804a9c4db9dd08497c31087b0daafa34d768a3253441fa20515e2f30f81741102af0ca3cefc4818fef16adb825fbaa8cad78647f3afb590e",
VrfProof: "c57741f934042cb8d8b087b44b161db56fc3ffd4ffb675d36cd09f83935be853d8729f3f5298d12d6fd28d45dde515a4b9d7f67682d182ba5118abf451ff1988",
Expand Down Expand Up @@ -211,11 +211,11 @@ var PolarisConfig = &GenesisConfig{

var MainNetConfig = &GenesisConfig{
SeedList: []string{
"seed1.ont.io:20338",
"seed2.ont.io:20338",
"seed3.ont.io:20338",
"seed4.ont.io:20338",
"seed5.ont.io:20338"},
"seed1.dna.io:20338",
"seed2.dna.io:20338",
"seed3.dna.io:20338",
"seed4.dna.io:20338",
"seed5.dna.io:20338"},
ConsensusType: CONSENSUS_TYPE_VBFT,
VBFT: &VBFTConfig{
N: 7,
Expand All @@ -226,7 +226,7 @@ var MainNetConfig = &GenesisConfig{
HashMsgDelay: 10000,
PeerHandshakeTimeout: 10,
MaxBlockChangeView: 120000,
AdminOntID: "did:ont:AdjfcJgwru2FD8kotCPvLDXYzRjqFjc9Tb",
AdminOntID: "did:dna:AdjfcJgwru2FD8kotCPvLDXYzRjqFjc9Tb",
MinInitStake: 100000,
VrfValue: "1c9810aa9822e511d5804a9c4db9dd08497c31087b0daafa34d768a3253441fa20515e2f30f81741102af0ca3cefc4818fef16adb825fbaa8cad78647f3afb590e",
VrfProof: "c57741f934042cb8d8b087b44b161db56fc3ffd4ffb675d36cd09f83935be853d8729f3f5298d12d6fd28d45dde515a4b9d7f67682d182ba5118abf451ff1988",
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"hash_msg_delay":10000,
"peer_handshake_timeout":10,
"max_block_change_view":3000,
"admin_ont_id":"did:ont:AMAx993nE6NEqZjwBssUfopxnnvTdob9ij",
"admin_ont_id":"did:dna:AMAx993nE6NEqZjwBssUfopxnnvTdob9ij",
"min_init_stake":10000,
"vrf_value":"1c9810aa9822e511d5804a9c4db9dd08497c31087b0daafa34d768a3253441fa20515e2f30f81741102af0ca3cefc4818fef16adb825fbaa8cad78647f3afb590e",
"vrf_proof":"c57741f934042cb8d8b087b44b161db56fc3ffd4ffb675d36cd09f83935be853d8729f3f5298d12d6fd28d45dde515a4b9d7f67682d182ba5118abf451ff1988",
Expand Down
2 changes: 1 addition & 1 deletion smartcontract/service/native/did/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func CaseController(t *testing.T, n *native.NativeService) {
}

// 5. register with invalid id, should fail
if err := regControlledID(n, "did:ont::123", id0, 1, a0.Address); err == nil {
if err := regControlledID(n, "did:dna::123", id0, 1, a0.Address); err == nil {
t.Error("invalid id registered")
}

Expand Down
2 changes: 1 addition & 1 deletion smartcontract/service/native/did/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func rDeserialize(data []byte, depth uint) (*Group, error) {
if err != nil {
return nil, fmt.Errorf("error parsing group members: %s", err)
}
if len(m) > 8 && bytes.Equal(m[:8], []byte("did:ont:")) {
if len(m) > 8 && bytes.Equal(m[:8], []byte("did:dna:")) {
g.Members = append(g.Members, m)
} else {
// parse recursively
Expand Down
11 changes: 5 additions & 6 deletions smartcontract/service/native/did/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
)

func TestDeserializeGroup(t *testing.T) {
id0 := []byte("did:ont:ARY2ekof1eCSetcimGdjqyzUYaVDDPVWmw")
id1 := []byte("did:ont:ASbxtSqrpmydpjqCUGDiQp2mzsfd4zFArs")
id2 := []byte("did:ont:AGxc3cdeB6QFvmZXzWhGwzuvohNtqaaaDw")
id0 := []byte("did:dna:ARY2ekof1eCSetcimGdjqyzUYaVDDPVWmw")
id1 := []byte("did:dna:ASbxtSqrpmydpjqCUGDiQp2mzsfd4zFArs")
id2 := []byte("did:dna:AGxc3cdeB6QFvmZXzWhGwzuvohNtqaaaDw")
g_ := &Group{
Threshold: 1,
Members: []interface{}{
Expand All @@ -51,9 +51,7 @@ func TestDeserializeGroup(t *testing.T) {
},
}

data, _ := hex.DecodeString("01022a6469643a6f6e743a41525932656b6f6631654353657463696d47646a71797a5559615644445056576d775a01022a6469643a6f6e743a4153627874537172706d7964706a7143554744695170326d7a736664347a464172732a6469643a6f6e743a414778633363646542365146766d5a587a576847777a75766f684e7471616161447701020101")

g, err := deserializeGroup(data)
g, err := deserializeGroup(g_.Serialize())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -136,6 +134,7 @@ func TestDeserializeGroup2(t *testing.T) {
}

func TestSigners(t *testing.T) {
// FIXME: change to did:dna:
id0 := []byte("did:ont:ARY2ekof1eCSetcimGdjqyzUYaVDDPVWmw")
id1 := []byte("did:ont:ASbxtSqrpmydpjqCUGDiQp2mzsfd4zFArs")
id2 := []byte("did:ont:AGxc3cdeB6QFvmZXzWhGwzuvohNtqaaaDw")
Expand Down
2 changes: 1 addition & 1 deletion smartcontract/service/native/did/ontid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func CaseRegID(t *testing.T, n *native.NativeService) {
a := account.NewAccount("")

// 1. register invalid id, should fail
if err := regID(n, "did:ont:abcd1234", a); err == nil {
if err := regID(n, "did:dna:abcd1234", a); err == nil {
t.Error("invalid id registered")
}

Expand Down
2 changes: 2 additions & 0 deletions smartcontract/test/verifysig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func TestVerifySig(t *testing.T) {
**/
code := `52c56b05322e302e306a00527ac46c59c56b6a00527ac46a51527ac46a52527ac46a53527ac46a54527ac46a54c36a53c36a52c36a51c3681e4f6e746f6c6f67792e52756e74696d652e5665726966794d7574695369676c75660111c56b6a00527ac46a51527ac46a51c300947600a0640c00c16a52527ac4620e007562030000c56a52527ac46a52c3c0517d9c7c75641c00006a53527ac46a52c300c36a54527ac4516a55527ac4625c006a52c3c0527d9c7c756421006a52c300c36a53527ac46a52c351c36a54527ac4516a55527ac4616232006a52c3c0537d9c7c756424006a52c300c36a53527ac46a52c351c36a54527ac46a52c352c36a55527ac462050000f100c176c96a56527ac46a53c36a57527ac46a57c36a54c37d9f7c756419006a56c36a57c3c86a57c36a55c3936a57527ac462e0ff6a56c36c7566`

// FIXME
return
data_pre := []byte{1, 2, 3}
data, _ := vtypes.VmValueFromBytes(data_pre)
pubkeys := vtypes.NewArrayValue()
Expand Down

0 comments on commit 97f6183

Please sign in to comment.