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

fix: adding Sanitize() method to Data interface #168

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
95170b0
fix: handling nil value for `compare` method of decData
0xankit Dec 8, 2022
19574b3
Merge branch 'master' into 0xankit/decDatafixes
deepanshutr Dec 9, 2022
764911a
fix: add `sanitize` method to `Data` interface
0xankit Dec 9, 2022
8ac65d1
Merge branch '0xankit/decDatafixes' of github.com:AssetMantle/modules…
0xankit Dec 9, 2022
51f8a47
test: update test for GetID method
0xankit Dec 9, 2022
30aac7c
test(schema): add `sanitize` method for accAddressData
0xankit Dec 9, 2022
9338cd3
test(schema): add `sanitize` method for booleanData
0xankit Dec 9, 2022
9dac67c
test(schema): add `sanitize` method for heightData
0xankit Dec 9, 2022
9ec054d
test(schema): add `sanitize` method for idData
0xankit Dec 9, 2022
79299ce
test(schema): add `sanitize` method for listData
0xankit Dec 12, 2022
7a2be4b
test(schema): add `sanitize` method for stringData
0xankit Dec 12, 2022
d28cd94
closes #123
0xankit Dec 12, 2022
2576b11
test(schema): update tests for propertylist
0xankit Dec 13, 2022
7b266b5
tests(schema): closes #30
0xankit Dec 13, 2022
b5012c0
Merge branch 'master' of github.com:AssetMantle/modules into 0xankit/…
0xankit Dec 13, 2022
79a69e5
fix: resolving merge conflicts
0xankit Dec 13, 2022
feb7915
test(schema): update test for accAddressData compare method
0xankit Dec 13, 2022
1239590
Merge branch 'master' of github.com:AssetMantle/modules into 0xankit/…
0xankit Dec 14, 2022
e0d80a7
test: mock fix
0xankit Dec 14, 2022
7fe7c7c
test: closes #165
0xankit Dec 14, 2022
9d3e003
test(schema): update tests for propertyList
0xankit Dec 14, 2022
3eb6751
test(schema): add test for nil case in idList
0xankit Dec 14, 2022
f2b4a84
test(schema): add test for maintainers
0xankit Dec 14, 2022
12787d6
code refactoring
0xankit Dec 14, 2022
5e3a5d5
test(schema): add tests for order Documents
0xankit Dec 14, 2022
7a84786
code refactoring
0xankit Dec 14, 2022
33fecbd
fix(schema): add sanitize method for documents
0xankit Dec 15, 2022
8fad47f
test(schema): add tests for ids utilities
0xankit Dec 15, 2022
85797a4
fix(schema): add sanitize method for dataList
0xankit Dec 15, 2022
756cc1e
fix(schema): add sanitize method for idList
0xankit Dec 15, 2022
3045e99
fix(schema): add sanitize method for propertyList
0xankit Dec 16, 2022
747f4df
fix: add sanitize method for lists
0xankit Dec 16, 2022
cbd3307
tests(schema): add tests for storeKeyPrefix
0xankit Dec 16, 2022
ce0cf08
test(schema): add tests for splitIDs ID
0xankit Dec 16, 2022
aac9b1d
test(schema): add tests for ownableID
0xankit Dec 16, 2022
e4833a5
test(schema): add tests for assetID
0xankit Dec 19, 2022
97593be
test(schema): add tests for classification IDs
0xankit Dec 19, 2022
cffbfa6
test(schema): add tests for identityIDs
0xankit Dec 19, 2022
63a607b
test(schema): add tests for maintainerID
0xankit Dec 20, 2022
0a5fb29
test(schema): add tests for orderID
0xankit Dec 20, 2022
5709958
code refactoring
0xankit Dec 21, 2022
a4eddc7
Merge pull request #181 from AssetMantle/0xankit/schemaTests
0xankit Dec 21, 2022
3004412
Merge branch '0xankit/ReadDataStringSanitize' of github.com:AssetMant…
0xankit Dec 21, 2022
37f268f
Merge branch '0xankit/decDatafixes' of github.com:AssetMantle/modules…
0xankit Dec 21, 2022
342dc34
Merge branch '0xankit/sanitizeData' of github.com:AssetMantle/modules…
0xankit Dec 21, 2022
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
3 changes: 3 additions & 0 deletions schema/data/base/decData.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func (decData decData) Compare(listable traits.Listable) int {
if err != nil {
panic(err)
}
if decData.Value.Int == nil {
0xankit marked this conversation as resolved.
Show resolved Hide resolved
decData.Value = sdkTypes.ZeroDec()
}

if decData.Value.GT(compareDecData.Value) {
return 1
Expand Down
24 changes: 8 additions & 16 deletions schema/data/base/decData_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,21 @@ func Test_decData_GenerateHashID(t *testing.T) {
Value types.Dec
}
tests := []struct {
name string
fields fields
want ids.HashID
wantPanic bool
name string
fields fields
want ids.HashID
}{
// TODO: Update Unit tests after fix
{"panic case with nil", fields{types.Dec{}}, baseIDs.GenerateHashID([]byte{}), true}, // TODO: Check if Panic case for nil Dec is expected behaviour
{"+ve with zero dec", fields{types.ZeroDec()}, baseIDs.GenerateHashID(), false},
{"+ve", fields{types.NewDec(100)}, baseIDs.GenerateHashID(decData{types.NewDec(100)}.Bytes()), false},
{"+ve with -ve Dec", fields{types.NewDec(-100)}, baseIDs.GenerateHashID(decData{types.NewDec(-100)}.Bytes()), false},
{"+ve with nil", fields{types.Dec{}}, baseIDs.GenerateHashID([]byte{})},
{"+ve with zero dec", fields{types.ZeroDec()}, baseIDs.GenerateHashID()},
{"+ve", fields{types.NewDec(100)}, baseIDs.GenerateHashID(decData{types.NewDec(100)}.Bytes())},
{"+ve with -ve Dec", fields{types.NewDec(-100)}, baseIDs.GenerateHashID(decData{types.NewDec(-100)}.Bytes())},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
decData := decData{
Value: tt.fields.Value,
}
if tt.wantPanic {
require.Panics(t, func() {
decData.GenerateHashID()
})
} else {
assert.Equalf(t, tt.want, decData.GenerateHashID(), "GenerateHashID()")
}
assert.Equalf(t, tt.want, decData.GenerateHashID(), "GenerateHashID()")

})
}
Expand Down