Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "uri" for MsgModify and deprecate the old ones #900

Merged
merged 11 commits into from
Feb 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests
0Tech committed Feb 14, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit e35e924fbe85dc47880997e43c9fa3bb224836da
42 changes: 37 additions & 5 deletions x/collection/event_test.go
Original file line number Diff line number Diff line change
@@ -344,11 +344,19 @@ func TestNewEventModifyCollection(t *testing.T) {
event := collection.EventModifiedContract{
ContractId: str(),
Operator: str(),
Changes: []collection.Attribute{{
Key: collection.AttributeKeyName.String(),
Value: str(),
}},
}
Changes: []collection.Attribute{
{
Key: collection.AttributeKeyName.String(),
Value: str(),
},
{
Key: collection.AttributeKeyBaseImgURI.String(),
Value: str(),
},
},
}
collection.UpdateEventModifiedContract(&event)

legacies := collection.NewEventModifyCollection(event)
require.Greater(t, len(legacies), 1)

@@ -956,3 +964,27 @@ func TestNewEventOperationRootChanged(t *testing.T) {
require.True(t, assertAttribute(legacy, key.String(), value), key)
}
}

func TestUpdateModifiedContract(t *testing.T) {
rand.Seed(time.Now().UnixNano())
str := func() string { return randomString(8) }

event := collection.EventModifiedContract{
ContractId: str(),
Operator: str(),
Changes: []collection.Attribute{
{
Key: collection.AttributeKeyName.String(),
Value: str(),
},
{
Key: collection.AttributeKeyBaseImgURI.String(),
Value: str(),
},
},
}
collection.UpdateEventModifiedContract(&event)

newChange := event.Changes[len(event.Changes) - 1]
require.Equal(t, collection.AttributeKeyURI.String(), newChange.Key)
}
42 changes: 37 additions & 5 deletions x/token/event_test.go
Original file line number Diff line number Diff line change
@@ -171,11 +171,19 @@ func TestNewEventModifyToken(t *testing.T) {
event := token.EventModified{
ContractId: str(),
Operator: str(),
Changes: []token.Attribute{{
Key: token.AttributeKeyName.String(),
Value: str(),
}},
}
Changes: []token.Attribute{
{
Key: token.AttributeKeyName.String(),
Value: str(),
},
{
Key: token.AttributeKeyImageURI.String(),
Value: str(),
},
},
}
token.UpdateEventModified(&event)

legacies := token.NewEventModifyToken(event)
require.Greater(t, len(legacies), 1)

@@ -384,3 +392,27 @@ func TestNewEventApproveToken(t *testing.T) {
require.True(t, assertAttribute(legacy, key.String(), value), key)
}
}

func TestUpdateModified(t *testing.T) {
rand.Seed(time.Now().UnixNano())
str := func() string { return randomString(8) }

event := token.EventModified{
ContractId: str(),
Operator: str(),
Changes: []token.Attribute{
{
Key: token.AttributeKeyName.String(),
Value: str(),
},
{
Key: token.AttributeKeyImageURI.String(),
Value: str(),
},
},
}
token.UpdateEventModified(&event)

newChange := event.Changes[len(event.Changes) - 1]
require.Equal(t, token.AttributeKeyURI.String(), newChange.Key)
}