mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
54 lines
1013 B
Go
54 lines
1013 B
Go
package cache_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/cache"
|
|
forkchoicetypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/forkchoice/types"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAttestationCache_RoundTrip(t *testing.T) {
|
|
c := cache.NewAttestationCache()
|
|
|
|
a := c.Get()
|
|
require.Nil(t, a)
|
|
|
|
insert := &cache.AttestationConsensusData{
|
|
Slot: 1,
|
|
HeadRoot: []byte{1},
|
|
Target: forkchoicetypes.Checkpoint{
|
|
Epoch: 2,
|
|
Root: [32]byte{3},
|
|
},
|
|
Source: forkchoicetypes.Checkpoint{
|
|
Epoch: 4,
|
|
Root: [32]byte{5},
|
|
},
|
|
}
|
|
err := c.Put(insert)
|
|
require.NoError(t, err)
|
|
|
|
a = c.Get()
|
|
require.Equal(t, insert, a)
|
|
|
|
insert = &cache.AttestationConsensusData{
|
|
Slot: 6,
|
|
HeadRoot: []byte{7},
|
|
Target: forkchoicetypes.Checkpoint{
|
|
Epoch: 8,
|
|
Root: [32]byte{9},
|
|
},
|
|
Source: forkchoicetypes.Checkpoint{
|
|
Epoch: 10,
|
|
Root: [32]byte{11},
|
|
},
|
|
}
|
|
|
|
err = c.Put(insert)
|
|
require.NoError(t, err)
|
|
|
|
a = c.Get()
|
|
require.Equal(t, insert, a)
|
|
}
|