From ecded70bafd68a59a8adcc71973735795be8de4e Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 29 May 2023 17:47:49 +0300 Subject: [PATCH] mempool: add test for malicious behaviour with Conflicts attribute --- pkg/core/mempool/mem_pool_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index 1d6514ee8..38e0d8d5a 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -548,6 +548,17 @@ func TestMempoolAddRemoveConflicts(t *testing.T) { require.NoError(t, mp.Add(tx14, fs)) err := mp.Add(tx15, fs) require.ErrorIs(t, err, ErrConflictsAttribute) + + // tx16 is malicious and will be sent in the end. + capacity = 10000 + mp = New(capacity, 0, false, nil) + tx16 := getConflictsTx(smallNetFee + 1) + for i := 0; i < mp.capacity-1; i++ { + require.NoError(t, mp.Add(getConflictsTx(smallNetFee, tx16.Hash()), fs)) + } + require.Equal(t, capacity-1, mp.Count()) + require.NoError(t, mp.Add(tx16, fs)) + require.Equal(t, 1, mp.Count()) } func TestMempoolAddWithDataGetData(t *testing.T) {