Skip to content

Commit

Permalink
[TEST] optimize unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
myth committed May 17, 2024
1 parent b056c6d commit fec2607
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/blockchain/pow/pow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestProofOfWork_prepareHashData(t *testing.T) {
block := &block.Block{
Index: 1,
Timestamp: 1715858482,
PrevBlockHash: []byte("��Q��@�G���-!�vO��M;QE���IJB"),
PrevBlockHash: []byte{0x7, 0xef, 0xbf, 0xbd, 0x19, 0xef, 0xbf, 0xbd, 0x51, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x40, 0xef, 0xbf, 0xbd, 0x47, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x2d, 0x21, 0xef, 0xbf, 0xbd, 0x76, 0x4f, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x4d, 0x3b, 0x7, 0x14, 0x51, 0x45, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xc4, 0xb2, 0x42},
Data: []byte("123213"),
}
pow := NewProofOfWork(block)
Expand All @@ -95,15 +95,12 @@ func TestProofOfWork_isNonceValid(t *testing.T) {
block := &block.Block{
Index: 1,
Timestamp: 1715858482,
PrevBlockHash: []byte("��Q��@�G���-!�vO��M;QE���IJB"),
PrevBlockHash: []byte{0x7, 0xef, 0xbf, 0xbd, 0x19, 0xef, 0xbf, 0xbd, 0x51, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x40, 0xef, 0xbf, 0xbd, 0x47, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x2d, 0x21, 0xef, 0xbf, 0xbd, 0x76, 0x4f, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x4d, 0x3b, 0x7, 0x14, 0x51, 0x45, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xc4, 0xb2, 0x42},
Data: []byte("123213"),
}
pow := NewProofOfWork(block)
expectedNonceList := []int{20, 79}
for i := range 100 {
if pow.isNonceValid(int64(i)) {
}
assert.True(t, pow.isNonceValid(int64(i)) == slices.Contains(expectedNonceList, i))
}

}

0 comments on commit fec2607

Please sign in to comment.