Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
algoidan committed Oct 23, 2022
1 parent 9504705 commit dda383d
Showing 1 changed file with 1 addition and 200 deletions.
201 changes: 1 addition & 200 deletions stateproof/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1486,13 +1486,13 @@ func TestWorker_LoadsBuilderAndSignatureUponMsgRecv(t *testing.T) {
_, exists := w.builders[msg.Round]
require.False(t, exists)
fwd, err := w.handleSig(msg, msg.SignerAddress)
// we expect the handler to ignore the signature since the builder and the old signature were loaded
require.Equal(t, network.Ignore, fwd)
require.NoError(t, err)
_, exists = w.builders[msg.Round]
require.True(t, exists)

// verify that builders can be loaded even if there are no signatures

w.builders = make(map[basics.Round]builder)
_, exists = w.builders[msg.Round]
require.False(t, exists)
Expand All @@ -1517,202 +1517,3 @@ func TestWorker_LoadsBuilderAndSignatureUponMsgRecv(t *testing.T) {
_, exists = w.builders[msg.Round]
require.False(t, exists)
}

//
//func TestWorker_LoadPersistentBuilders(t *testing.T) {
// partitiontest.PartitionTest(t)
// a := require.New(t)
//
// var keys []account.Participation
// for i := 0; i < 2; i++ {
// var parent basics.Address
// crypto.RandBytes(parent[:])
// p := newPartKey(t, parent)
// defer p.Close()
// keys = append(keys, p.Participation)
// }
//
// s := newWorkerStubs(t, keys, 10)
// w := newTestWorker(t, s)
// w.Start()
//
//
// proto := config.Consensus[protocol.ConsensusCurrentVersion]
// s.advanceLatest(10*proto.StateProofInterval + proto.StateProofInterval/2) // 512, 768, 1024, ... (9 StateProofs)
//
// // Wait on all signatures (should be many since they're re-broadcasted until the StateProof transaction is accepted)
// for {
// _, err := s.waitOnSigWithTimeout(time.Second * 2)
// if err != nil {
// break
// }
// }
// w.Shutdown()
//}

//
//func TestBuilderLoadsFromDisk(t *testing.T) {
// partitiontest.PartitionTest(t)
// a := require.New(t)
//
// var keys []account.Participation
// for i := 0; i < 2; i++ {
// var parent basics.Address
// crypto.RandBytes(parent[:])
// p := newPartKey(t, parent)
// defer p.Close()
// keys = append(keys, p.Participation)
// }
//
// s := newWorkerStubs(t, keys, 10)
// w := newTestWorker(t, s)
// w.Start()
// defer w.Shutdown()
//
// proto := config.Consensus[protocol.ConsensusCurrentVersion]
// s.advanceLatest(10*proto.StateProofInterval + proto.StateProofInterval/2) // 512, 768, 1024, ... (9 StateProofs)
//
// // Wait on all signatures
// for {
// _, err := s.waitOnSigWithTimeout(time.Second * 2)
// if err != nil {
// break
// }
// }
//
// w.mu.Lock()
// bldrForComparission := w.builders[512]
// w.mu.Unlock()
//
// // running through the builder with no ram or ledger:
// // without the Disk, it isn't possible to fetch the builder correctly.
// w.mu.Lock()
// w.builders = map[basics.Round]builder{}
// w.ledger = nil
//
// _, err := w.loadOrCreateBuilder(512)
// w.mu.Unlock()
// a.NoError(err)
//
// // without accessing the DB and the ledger fetching is not possible:
// w.persistBuilders = false
// a.Panics(func() {
// w.mu.Lock()
// defer w.mu.Unlock()
//
// w.loadOrCreateBuilder(512)
// })
//
// // Loading the builders from the disk, along with their sigs.
// w.persistBuilders = true
// w.initBuilders()
//
// w.mu.Lock()
// a.Equal(bldrForComparission, w.builders[512])
// w.mu.Unlock()
//}
//
//func TestBuilderFromDiskCreatesMessage(t *testing.T) {
// partitiontest.PartitionTest(t)
// a := require.New(t)
//
// var keys []account.Participation
// for i := 0; i < 2; i++ {
// var parent basics.Address
// crypto.RandBytes(parent[:])
// p := newPartKey(t, parent)
// defer p.Close()
// keys = append(keys, p.Participation)
// }
//
// s := newWorkerStubs(t, keys, 10)
// w := newTestWorker(t, s)
// w.Start()
// defer w.Shutdown()
//
// proto := config.Consensus[protocol.ConsensusCurrentVersion]
// s.advanceLatest(10*proto.StateProofInterval + proto.StateProofInterval/2) // 512, 768, 1024, ... (9 StateProofs)
//
// // Wait on all signatures
// for {
// _, err := s.waitOnSigWithTimeout(time.Second * 2)
// if err != nil {
// break
// }
// }
// // dropping inRam builder making:
// w.mu.Lock()
// w.ledger = nil
// w.builders = map[basics.Round]builder{}
// bldr, err := w.loadOrCreateBuilder(512)
// w.mu.Unlock()
//
// a.NoError(err)
// a.NotEmpty(bldr.Message)
//}
//
//func TestLoadBuilderFromDiskWithSigs(t *testing.T) {
// partitiontest.PartitionTest(t)
// a := require.New(t)
//
// var keys []account.Participation
// for i := 0; i < 2; i++ {
// var parent basics.Address
// crypto.RandBytes(parent[:])
// p := newPartKey(t, parent)
// defer p.Close()
// keys = append(keys, p.Participation)
// }
//
// s := newWorkerStubs(t, keys, 10)
// w := newTestWorker(t, s)
// w.Start()
// defer w.Shutdown()
//
// proto := config.Consensus[protocol.ConsensusCurrentVersion]
// s.advanceLatest(10*proto.StateProofInterval + proto.StateProofInterval/2) // 512, 768, 1024, ... (9 StateProofs)
//
// // Wait on all signatures
// for {
// _, err := s.waitOnSigWithTimeout(time.Second * 2)
// if err != nil {
// break
// }
// }
//
// var sigs map[basics.Round][]pendingSig
// a.NoError(w.db.Atomic(func(_ context.Context, tx *sql.Tx) error {
// tmp, err := getPendingSigsFromThisNode(tx)
// a.NoError(err)
// sigs = tmp
// // deleting the sig ensures we'll be able to add it using the `handleSig` function.
// _, err = tx.Exec("DELETE FROM sigs where sprnd=512 AND signer=?", sigs[512][0].signer[:])
// return err
// }))
// sig := sigs[512][0]
// a.NotEmpty(sig)
//
// // dropping inRam builder making:
//
// a.NoError(w.db.Atomic(func(_ context.Context, tx *sql.Tx) error {
// _, err := getBuilder(tx, 512) // ensuring builder in DB.
// return err
// }))
//
// w.mu.Lock()
// comparisionBuilder := w.builders[512]
// w.mu.Unlock()
//
// w.builders = map[basics.Round]builder{}
//
// _, err := w.handleSig(sigFromAddr{
// SignerAddress: sig.signer,
// Round: 512,
// Sig: sig.sig,
// }, nil)
// a.NoError(err)
//
// w.mu.Lock()
// a.Equal(comparisionBuilder, w.builders[512])
// w.mu.Unlock()
//}

0 comments on commit dda383d

Please sign in to comment.