Skip to content

Commit

Permalink
clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Feb 2, 2023
1 parent dc3f2ff commit f2d021d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/gorilla/rpc v1.2.0
github.com/gorilla/websocket v1.5.0
github.com/gtank/merlin v0.1.1
github.com/holiman/bloomfilter/v2 v2.0.3
github.com/ipfs/go-ds-badger2 v0.1.3
github.com/jpillora/ipfilter v1.2.8
github.com/klauspost/compress v1.15.15
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
Expand Down
22 changes: 12 additions & 10 deletions lib/babe/build_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/lib/transaction"
"github.com/ChainSafe/gossamer/pkg/scale"
Expand Down Expand Up @@ -242,12 +243,13 @@ func TestBuildAndApplyExtrinsic(t *testing.T) {
}

func TestBuildAndApplyExtrinsic_InvalidPayment(t *testing.T) {
kr, err := keystore.NewSr25519Keyring()
require.NoError(t, err)

genesis, genesisTrie, genesisHeader := newWestendDevGenesisWithTrieAndHeader(t)
babeService := createTestService(t, ServiceConfig{}, genesis, genesisTrie, genesisHeader)

parentHash := common.MustHexToHash("0x35a28a7dbaf0ba07d1485b0f3da7757e3880509edc8c31d0850cb6dd6219361d")
header := types.NewHeader(parentHash, common.Hash{}, common.Hash{}, 1, types.NewDigest())

header := types.NewHeader(genesisHeader.Hash(), common.Hash{}, common.Hash{}, 1, types.NewDigest())
bestBlockHash := babeService.blockState.BestBlockHash()
rt, err := babeService.blockState.GetRuntime(bestBlockHash)
require.NoError(t, err)
Expand All @@ -266,18 +268,18 @@ func TestBuildAndApplyExtrinsic_InvalidPayment(t *testing.T) {
require.NoError(t, err)

rv := rt.Version()
bob, err := ctypes.NewMultiAddressFromHexAccountID(
"0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22")
charlie, err := ctypes.NewMultiAddressFromHexAccountID(
kr.KeyCharlie.Public().Hex())
require.NoError(t, err)

call, err := ctypes.NewCall(meta, "Balances.transfer", bob, ctypes.NewUCompactFromUInt(^uint64(0)))
call, err := ctypes.NewCall(meta, "Balances.transfer", charlie, ctypes.NewUCompactFromUInt(^uint64(0)))
require.NoError(t, err)

ext := ctypes.NewExtrinsic(call)
genHash, err := ctypes.NewHashFromHexString("0x35a28a7dbaf0ba07d1485b0f3da7757e3880509edc8c31d0850cb6dd6219361d")
genHash, err := ctypes.NewHashFromHexString(genesisHeader.Hash().String())
require.NoError(t, err)

o := ctypes.SignatureOptions{
so := ctypes.SignatureOptions{
BlockHash: genHash,
Era: ctypes.ExtrinsicEra{IsImmortalEra: true},
GenesisHash: genHash,
Expand All @@ -287,7 +289,7 @@ func TestBuildAndApplyExtrinsic_InvalidPayment(t *testing.T) {
TransactionVersion: ctypes.U32(rv.TransactionVersion),
}

err = ext.Sign(signature.TestKeyringPairAlice, o)
err = ext.Sign(signature.TestKeyringPairAlice, so)
require.NoError(t, err)

extEnc := bytes.Buffer{}
Expand All @@ -300,7 +302,7 @@ func TestBuildAndApplyExtrinsic_InvalidPayment(t *testing.T) {
err = determineErr(res)
_, ok := err.(*TransactionValidityError)
require.True(t, ok)
require.Equal(t, err.Error(), "transaction validity error: invalid payment")
require.Equal(t, "transaction validity error: invalid payment", err.Error())
}

func TestDecodeExtrinsicBody(t *testing.T) {
Expand Down

0 comments on commit f2d021d

Please sign in to comment.