forked from canopy-network/canopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx_test.go
More file actions
35 lines (29 loc) · 742 Bytes
/
Copy pathtx_test.go
File metadata and controls
35 lines (29 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controller
import (
"sync"
"testing"
"github.com/canopy-network/canopy/lib"
"github.com/stretchr/testify/require"
)
func TestGetPendingTxByHash(t *testing.T) {
c := &Controller{
Mempool: &Mempool{
cachedResults: lib.TxResults{
&lib.TxResult{TxHash: "abcdef1234"},
&lib.TxResult{TxHash: "1234567890"},
},
},
Mutex: &sync.Mutex{},
}
tx, found := c.GetPendingTxByHash("ABCDEF1234")
require.True(t, found)
require.NotNil(t, tx)
require.Equal(t, "abcdef1234", tx.TxHash)
tx, found = c.GetPendingTxByHash("0x1234567890")
require.True(t, found)
require.NotNil(t, tx)
require.Equal(t, "1234567890", tx.TxHash)
tx, found = c.GetPendingTxByHash("missing")
require.False(t, found)
require.Nil(t, tx)
}