mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
consensus: add tests for getTx
This commit is contained in:
parent
d803dffca8
commit
8d1f564411
1 changed files with 31 additions and 0 deletions
|
@ -56,6 +56,37 @@ func TestService_ValidatePayload(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestService_getTx(t *testing.T) {
|
||||
srv := newTestService(t)
|
||||
|
||||
t.Run("transaction in mempool", func(t *testing.T) {
|
||||
tx := newMinerTx(1234)
|
||||
h := tx.Hash()
|
||||
|
||||
require.Equal(t, nil, srv.getTx(h))
|
||||
|
||||
item := core.NewPoolItem(tx, new(feer))
|
||||
srv.Chain.GetMemPool().TryAdd(h, item)
|
||||
|
||||
got := srv.getTx(h)
|
||||
require.NotNil(t, got)
|
||||
require.Equal(t, h, got.Hash())
|
||||
})
|
||||
|
||||
t.Run("transaction in local cache", func(t *testing.T) {
|
||||
tx := newMinerTx(4321)
|
||||
h := tx.Hash()
|
||||
|
||||
require.Equal(t, nil, srv.getTx(h))
|
||||
|
||||
srv.txx.Add(tx)
|
||||
|
||||
got := srv.getTx(h)
|
||||
require.NotNil(t, got)
|
||||
require.Equal(t, h, got.Hash())
|
||||
})
|
||||
}
|
||||
|
||||
func TestService_OnPayload(t *testing.T) {
|
||||
srv := newTestService(t)
|
||||
|
||||
|
|
Loading…
Reference in a new issue