-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(collection): refactor overall unittests of
x/collection
(#1139)
* modify MsgOperatorBurnFT * clarify events * remove deterministic flag, always test for non-deterministic * add CHANGELOG * chore: refactor * chore: encoding unittest
- Loading branch information
Showing
5 changed files
with
616 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package testutil | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func MustJSONMarshal(v any) []byte { | ||
b, err := json.Marshal(v) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return b | ||
} | ||
|
||
func W(input string) []byte { | ||
return []byte(fmt.Sprintf("\"%s\"", input)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package testutil_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/Finschia/finschia-sdk/testutil" | ||
) | ||
|
||
func TestMustJSONMarshal(t *testing.T) { | ||
type tc struct { | ||
Name string `json:"myName"` | ||
Order string `json:"myOrder"` | ||
} | ||
|
||
a := tc{ | ||
Name: "test", | ||
Order: "first", | ||
} | ||
b := new(tc) | ||
|
||
marshaled := testutil.MustJSONMarshal(a) | ||
err := json.Unmarshal(marshaled, b) | ||
require.NoError(t, err) | ||
require.Equal(t, a, *b) | ||
require.Panics(t, func() { testutil.MustJSONMarshal(make(chan int)) }) | ||
} | ||
|
||
func TestW(t *testing.T) { | ||
require.Equal(t, []byte(`"test"`), testutil.W("test")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.