Skip to content

Commit

Permalink
✅ Add an ISCN ID test for omissible properties
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiJun0827 committed Mar 6, 2023
1 parent 8c6f960 commit 1f28b36
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions x/iscn/types/iscnmsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,42 @@ var (
ContentMetadata: IscnInput(`{}`),
}

msgCreateIscnRecord1NoNonce = MsgCreateIscnRecord{
createIscnRecord3 = IscnRecord{
RecordNotes: "",
ContentFingerprints: []string{},
Stakeholders: []IscnInput{},
ContentMetadata: IscnInput(`{}`),
}

createIscnRecord4 = IscnRecord{
ContentMetadata: IscnInput(`{
"emptyField": "",
"emptyArray": [],
"emptyObject": {}
}`),
}

msgCreateIscnRecord1NoNonce1 = MsgCreateIscnRecord{
From: addr1,
Record: createIscnRecord2,
}
msgCreateIscnRecord1NoNonce2 = MsgCreateIscnRecord{
From: addr1,
Record: createIscnRecord3,
}
msgCreateIscnRecord1NoNonce3 = MsgCreateIscnRecord{
From: addr1,
Record: createIscnRecord4,
}
msgCreateIscnRecord1Nonce1 = MsgCreateIscnRecord{
From: addr1,
Record: createIscnRecord2,
Nonce: 1,
}

msgCreateIscnRecordBytesNoNonce = []byte(`{"type":"likecoin-chain/MsgCreateIscnRecord","value":{"from":"like1ukmjl5s6pnw2txkvz2hd2n0f6dulw34h9rw5zn","record":{"contentMetadata":{}}}}`)
msgCreateIscnRecordBytesNonce1 = []byte(`{"type":"likecoin-chain/MsgCreateIscnRecord","value":{"from":"like1ukmjl5s6pnw2txkvz2hd2n0f6dulw34h9rw5zn","nonce":"1","record":{"contentMetadata":{}}}}`)
msgCreateIscnRecordBytesNoNonce1 = []byte(`{"type":"likecoin-chain/MsgCreateIscnRecord","value":{"from":"like1ukmjl5s6pnw2txkvz2hd2n0f6dulw34h9rw5zn","record":{"contentMetadata":{}}}}`)
msgCreateIscnRecordBytesNoNonce2 = []byte(`{"type":"likecoin-chain/MsgCreateIscnRecord","value":{"from":"like1ukmjl5s6pnw2txkvz2hd2n0f6dulw34h9rw5zn","record":{"contentMetadata":{"emptyArray":[],"emptyField":"","emptyObject":{}}}}}`)
msgCreateIscnRecordBytesNonce1 = []byte(`{"type":"likecoin-chain/MsgCreateIscnRecord","value":{"from":"like1ukmjl5s6pnw2txkvz2hd2n0f6dulw34h9rw5zn","nonce":"1","record":{"contentMetadata":{}}}}`)

registryName = "likecoin-chain"

Expand Down Expand Up @@ -163,8 +187,18 @@ func TestMsgCreateIscnRecord_GetSignBytes(t *testing.T) {
}{
{
name: "valid with no nonce",
msg: msgCreateIscnRecord1NoNonce,
want: msgCreateIscnRecordBytesNoNonce,
msg: msgCreateIscnRecord1NoNonce1,
want: msgCreateIscnRecordBytesNoNonce1,
},
{
name: "valid with no nonce and ignore empty optional fields in IscnRecord",
msg: msgCreateIscnRecord1NoNonce2,
want: msgCreateIscnRecordBytesNoNonce1,
},
{
name: "valid with no nonce and keep empty fields in ContentMetadata",
msg: msgCreateIscnRecord1NoNonce3,
want: msgCreateIscnRecordBytesNoNonce2,
},
{
name: "valid with assigned nonce",
Expand All @@ -189,7 +223,7 @@ func TestMsgCreateIscnRecord_GenerateNewIscnIdWithSeed(t *testing.T) {
}{
{
name: "valid with no nonce",
seed: msgCreateIscnRecordBytesNoNonce,
seed: msgCreateIscnRecordBytesNoNonce1,
want: iscnIdNoNonce,
},
{
Expand Down

0 comments on commit 1f28b36

Please sign in to comment.