Skip to content

Commit

Permalink
chore(end-to-end): Faster TestAuthorSubmitExtrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Apr 11, 2022
1 parent 52de6f8 commit d02eb44
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 d02eb44

Please sign in to comment.