Skip to content

Commit

Permalink
Faster TestAuthorSubmitExtrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Apr 11, 2022
1 parent 5493fce commit 3287691
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/rpc/rpc_02-author_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ChainSafe/gossamer/tests/utils"
"github.com/ChainSafe/gossamer/tests/utils/config"
"github.com/ChainSafe/gossamer/tests/utils/node"
"github.com/ChainSafe/gossamer/tests/utils/retry"
gsrpc "github.com/centrifuge/go-substrate-rpc-client/v3"
"github.com/centrifuge/go-substrate-rpc-client/v3/signature"
"github.com/centrifuge/go-substrate-rpc-client/v3/types"
Expand All @@ -37,11 +38,20 @@ func TestAuthorSubmitExtrinsic(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
node.InitAndStartTest(ctx, t, cancel)

time.Sleep(30 * time.Second) // wait for server to start and block 1 to be produced

api, err := gsrpc.NewSubstrateAPI(fmt.Sprintf("http://localhost:%s", node.GetRPCPort()))
require.NoError(t, err)

// Wait for the first block to be produced.
const retryWait = time.Second
err = retry.UntilOK(ctx, retryWait, func() (ok bool, err error) {
block, err := api.RPC.Chain.GetBlockLatest()
if err != nil {
return false, err
}
return block.Block.Header.Number > 0, nil
})
require.NoError(t, err)

meta, err := api.RPC.State.GetMetadataLatest()
require.NoError(t, err)

Expand Down

0 comments on commit 3287691

Please sign in to comment.