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