-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hariom/gno-test-patterns
- Loading branch information
Showing
31 changed files
with
393 additions
and
178 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
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
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
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
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
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
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
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,40 @@ | ||
package gnolang | ||
|
||
import ( | ||
"math/big" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/jaekwon/testify/require" | ||
|
||
"github.com/gnolang/gno/tm2/pkg/amino" | ||
) | ||
|
||
// Tries to reproduce the bug #1036 on all registered types | ||
func TestAminoJSONRegisteredTypes(t *testing.T) { | ||
for _, typ := range Package.Types { | ||
// Instantiate registered type | ||
x := reflect.New(typ.Type).Interface() | ||
|
||
// Call MarshalAmino directly on 'x' | ||
_, err := amino.MarshalJSON(x) | ||
require.NoError(t, err, "marshal type %s", typ.Type.Name()) | ||
|
||
// Call MarshalAmino on a struct that embeds 'x' in a field of type any | ||
xx := struct { | ||
X any | ||
}{X: x} | ||
_, err = amino.MarshalJSON(xx) | ||
require.NoError(t, err, "marshal type %s from struct", typ.Type.Name()) | ||
} | ||
|
||
// Check unmarshaling (can't reuse package.Types because some internal values | ||
// must be filled properly | ||
bi := BigintValue{V: big.NewInt(1)} | ||
bz := amino.MustMarshalJSON(bi) | ||
amino.MustUnmarshalJSON(bz, &bi) | ||
// Check unmarshaling with an embedding struct | ||
x := struct{ X any }{X: bi} | ||
bz = amino.MustMarshalJSON(x) | ||
amino.MustUnmarshalJSON(bz, &x) | ||
} |
Oops, something went wrong.