lotus/itests/dup_mpool_messages_test.go

61 lines
1.5 KiB
Go
Raw Permalink Normal View History

2022-08-17 16:38:23 +00:00
package itests
import (
"context"
2022-08-17 18:02:53 +00:00
"testing"
"time"
uuid2 "github.com/google/uuid"
"github.com/stretchr/testify/require"
2022-08-17 16:38:23 +00:00
"github.com/filecoin-project/go-state-types/big"
2022-08-17 18:02:53 +00:00
2022-08-17 16:38:23 +00:00
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit"
)
func TestDuplicateMpoolMessages(t *testing.T) {
kit.QuietMiningLogs()
blockTime := 50 * time.Millisecond
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs())
ens.InterconnectAll().BeginMining(blockTime)
msgBal := &types.Message{
From: client.DefaultKey.Address,
To: builtin.BurntFundsActorAddr,
Value: big.NewInt(10000),
}
uuid := uuid2.New()
msgSpec := &api.MessageSendSpec{MsgUuid: uuid}
msg, err := client.MpoolPushMessage(ctx, msgBal, msgSpec)
require.NoError(t, err)
2022-08-17 18:14:07 +00:00
_, err = client.StateWaitMsg(ctx, msg.Cid(), 3, api.LookbackNoLimit, true)
require.NoError(t, err)
2022-08-17 16:38:23 +00:00
remBal, err := client.WalletBalance(ctx, client.DefaultKey.Address)
require.NoError(t, err)
msg2, err := client.MpoolPushMessage(ctx, msgBal, msgSpec)
require.NoError(t, err)
require.Equal(t, msg, msg2)
_, err = client.StateWaitMsg(ctx, msg2.Cid(), 3, api.LookbackNoLimit, true)
require.NoError(t, err)
2022-08-17 16:38:23 +00:00
currBal, err := client.WalletBalance(ctx, client.DefaultKey.Address)
require.NoError(t, err)
require.Equal(t, remBal, currBal)
}