mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 05:38:55 +00:00
12524ae8dd
* fix bug in eth1 data vote count increases * updating attester slashings * is double vote and attester pseudocode * attester slashing revamp complete * exits processing complete * all block operations aligned to spec * completed test revamp * builds properly * all done FINALLY * deprecate all instances of old randao logic * fix all broken tests and cleanup randao references across repo * builds but tests failing * fixing broken chaintests * only chaintests fail now * randao fully updated * add bls todo * lint * travis * fix unresolved property in struct * remove used randao var
81 lines
2.4 KiB
Go
81 lines
2.4 KiB
Go
package backend
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/trieutil"
|
|
)
|
|
|
|
func TestSimulatedBackendStop(t *testing.T) {
|
|
|
|
backend, err := NewSimulatedBackend()
|
|
if err != nil {
|
|
t.Fatalf("Could not create a new simulated backedn %v", err)
|
|
}
|
|
if err := backend.Shutdown(); err != nil {
|
|
t.Errorf("Could not successfully shutdown simulated backend %v", err)
|
|
}
|
|
}
|
|
|
|
func TestGenerateBlocks(t *testing.T) {
|
|
backend, err := NewSimulatedBackend()
|
|
if err != nil {
|
|
t.Fatalf("Could not create a new simulated backedn %v", err)
|
|
}
|
|
|
|
initialDeposits, err := generateInitialSimulatedDeposits(1000)
|
|
if err != nil {
|
|
t.Fatalf("Could not simulate initial validator deposits: %v", err)
|
|
}
|
|
if err := backend.setupBeaconStateAndGenesisBlock(initialDeposits); err != nil {
|
|
t.Fatalf("Could not set up beacon state and initialize genesis block %v", err)
|
|
}
|
|
backend.depositTrie = trieutil.NewDepositTrie()
|
|
|
|
slotLimit := 250
|
|
|
|
for i := 0; i < slotLimit; i++ {
|
|
if err := backend.GenerateBlockAndAdvanceChain(&SimulatedObjects{}); err != nil {
|
|
t.Fatalf("Could not generate block and transition state successfully %v for slot %d", err, backend.state.Slot+1)
|
|
}
|
|
if backend.inMemoryBlocks[len(backend.inMemoryBlocks)-1].Slot != backend.state.Slot {
|
|
t.Errorf("In memory Blocks do not have the same last slot as the state, expected %d but got %d",
|
|
backend.state.Slot, backend.inMemoryBlocks[len(backend.inMemoryBlocks)-1])
|
|
}
|
|
}
|
|
|
|
if backend.state.Slot != uint64(slotLimit) {
|
|
t.Errorf("Unequal state slot and expected slot %d %d", backend.state.Slot, slotLimit)
|
|
}
|
|
|
|
}
|
|
|
|
func TestGenerateNilBlocks(t *testing.T) {
|
|
backend, err := NewSimulatedBackend()
|
|
if err != nil {
|
|
t.Fatalf("Could not create a new simulated backedn %v", err)
|
|
}
|
|
|
|
initialDeposits, err := generateInitialSimulatedDeposits(1000)
|
|
if err != nil {
|
|
t.Fatalf("Could not simulate initial validator deposits: %v", err)
|
|
}
|
|
if err := backend.setupBeaconStateAndGenesisBlock(initialDeposits); err != nil {
|
|
t.Fatalf("Could not set up beacon state and initialize genesis block %v", err)
|
|
}
|
|
backend.depositTrie = trieutil.NewDepositTrie()
|
|
|
|
slotLimit := 100
|
|
|
|
for i := 0; i < slotLimit; i++ {
|
|
if err := backend.GenerateNilBlockAndAdvanceChain(); err != nil {
|
|
t.Fatalf("Could not generate block and transition state successfully %v for slot %d", err, backend.state.Slot+1)
|
|
}
|
|
}
|
|
|
|
if backend.state.Slot != uint64(slotLimit) {
|
|
t.Errorf("Unequal state slot and expected slot %d %d", backend.state.Slot, slotLimit)
|
|
}
|
|
|
|
}
|