Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit d9077af

Browse files
authored
Merge pull request #980 from iotaledger/cleanup-nil-payload-test
Cleanup nil payload test
2 parents 61046c3 + 1d9e9d2 commit d9077af

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

tools/docker-network/tests/nil_payload_test.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package tests
44

55
import (
66
"context"
7-
"fmt"
87
"testing"
98

109
"github.com/stretchr/testify/require"
@@ -14,11 +13,8 @@ import (
1413
"github.com/iotaledger/iota-core/tools/docker-network/tests/dockertestframework"
1514
)
1615

17-
// Test_AccountTransitions follows the account state transition flow described in:
18-
// 1. Create account-1.
19-
// 2. Create account-2.
20-
// 3. account-1 requests faucet funds then allots 1000 mana to account-2.
21-
// 4. account-2 requests faucet funds then creates native tokens.
16+
// Test_Payload_Nil tests that sending a nil payload does not result in a panic.
17+
// This is a test to ensure issue #978 is fixed.
2218
func Test_Payload_Nil_Test(t *testing.T) {
2319
d := dockertestframework.NewDockerTestFramework(t,
2420
dockertestframework.WithProtocolParametersOptions(dockertestframework.ShortSlotsAndEpochsProtocolParametersOptionsFunc()...),
@@ -42,20 +38,12 @@ func Test_Payload_Nil_Test(t *testing.T) {
4238
t.Cleanup(cancel)
4339

4440
// create account-1
45-
accounts := d.CreateAccountsFromFaucet(ctx, 2, "account-1", "account-2")
46-
account1 := accounts[0]
47-
account2 := accounts[1]
41+
account := d.CreateAccountFromFaucet("account-1")
4842

49-
// allot 1000 mana from account-1 to account-2
50-
fmt.Println("Allotting mana from account-1 to account-2")
51-
d.RequestFaucetFundsAndAllotManaTo(account1.Wallet(), account2.Account(), 1000)
52-
53-
// create native token
54-
fmt.Println("Creating native token")
55-
d.CreateNativeToken(account1.Wallet(), 5_000_000, 10_000_000_000)
56-
57-
blk := lo.PanicOnErr(account1.Wallet().CreateBasicBlock(ctx, "something", mock.WithPayload(nil)))
43+
// Issue a block with a nil payload.
44+
blk := lo.PanicOnErr(account.Wallet().CreateBasicBlock(ctx, "something", mock.WithPayload(nil)))
5845
d.SubmitBlock(ctx, blk.ProtocolBlock())
5946

47+
// Wait for the epoch end to ensure the test does not exit early.
6048
d.AwaitEpochFinalized()
6149
}

0 commit comments

Comments
 (0)