Some checks failed
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
Build & Push SDK Proto Builder / build (push) Has been cancelled
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package ledger
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
|
)
|
|
|
|
func checkAminoJSON(t *testing.T, src, dst any, isNil bool) {
|
|
t.Helper()
|
|
|
|
// Marshal to JSON bytes.
|
|
js, err := cdc.MarshalJSON(src)
|
|
require.Nil(t, err, "%+v", err)
|
|
if isNil {
|
|
require.Equal(t, string(js), `null`)
|
|
} else {
|
|
require.Contains(t, string(js), `"type":`)
|
|
require.Contains(t, string(js), `"value":`)
|
|
}
|
|
// Unmarshal.
|
|
err = cdc.UnmarshalJSON(js, dst)
|
|
require.Nil(t, err, "%+v", err)
|
|
}
|
|
|
|
/*
|
|
func ExamplePrintRegisteredTypes() { //nolint:govet // ignore for examples
|
|
_ = cdc.PrintTypes(os.Stdout)
|
|
// | Type | Name | Prefix | Length | Notes |
|
|
// | ---- | ---- | ------ | ----- | ------ |
|
|
// | PrivKeyLedgerSecp256k1 | tendermint/PrivKeyLedgerSecp256k1 | 0x10CAB393 | variable | |
|
|
// | PubKey | tendermint/PubKeyEd25519 | 0x1624DE64 | variable | |
|
|
// | PubKey | tendermint/PubKeySr25519 | 0x0DFB1005 | variable | |
|
|
// | PubKey | tendermint/PubKeySecp256k1 | 0xEB5AE987 | variable | |
|
|
// | PubKeyMultisigThreshold | tendermint/PubKeyMultisigThreshold | 0x22C1F7E2 | variable | |
|
|
// | PrivKey | tendermint/PrivKeyEd25519 | 0xA3288910 | variable | |
|
|
// | PrivKey | tendermint/PrivKeySr25519 | 0x2F82D78B | variable | |
|
|
// | PrivKey | tendermint/PrivKeySecp256k1 | 0xE1B0F79B | variable | |
|
|
}
|
|
*/
|
|
|
|
func TestNilEncodings(t *testing.T) {
|
|
// Check nil Signature.
|
|
var a, b []byte
|
|
checkAminoJSON(t, &a, &b, true)
|
|
require.EqualValues(t, a, b)
|
|
|
|
// Check nil PubKey.
|
|
var c, d cryptotypes.PubKey
|
|
checkAminoJSON(t, &c, &d, true)
|
|
require.EqualValues(t, c, d)
|
|
|
|
// Check nil PrivKey.
|
|
var e, f cryptotypes.PrivKey
|
|
checkAminoJSON(t, &e, &f, true)
|
|
require.EqualValues(t, e, f)
|
|
}
|