github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/core/state/statedb_candidate_test.go (about)

     1  package state
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/intfoundation/intchain/common"
     6  	"github.com/intfoundation/intchain/core/rawdb"
     7  	"testing"
     8  )
     9  
    10  func TestUpdateCandidateSet(t *testing.T) {
    11  	db := rawdb.NewMemoryDatabase()
    12  	state, _ := New(common.Hash{}, NewDatabase(db))
    13  
    14  	for i := byte(0); i < 255; i++ {
    15  		addr := common.BytesToAddress([]byte{i})
    16  		state.MarkAddressCandidate(addr)
    17  	}
    18  
    19  	state.ClearCandidateSetByAddress(common.BytesToAddress([]byte{byte(1)}))
    20  
    21  	canSet := state.candidateSet
    22  	i := 0
    23  	for k, v := range canSet {
    24  		fmt.Printf("index: %v ", i)
    25  		fmt.Printf("candidate set: %v -> %v\n", k, v)
    26  		i++
    27  	}
    28  }