Skip to content

Commit

Permalink
Add new fields to wo and header hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed Oct 1, 2024
1 parent 51a80da commit 5a938b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions core/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ func headerTestData() (*Header, common.Hash) {
extra: []byte("SGVsbG8gd29ybGQ="),
stateLimit: 1234567,
stateUsed: 1234567,
exchangeRate: big.NewInt(123456789),
quaiToQi: big.NewInt(123456789),
qiToQuai: big.NewInt(123456789),
}

return header, header.Hash()
}

func TestHeaderHash(t *testing.T) {
_, hash := headerTestData()
correctHash := common.HexToHash("0xc8110a0bb8fe2f98081d1202ce0dcf299dc42a14df271a994e1925c78931177b")
require.Equal(t, hash, correctHash, "Hash not equal to expected hash")
correctHash := common.HexToHash("0x708a539748c808aa9c7c706c2828ebe802bad88f95980fd7eda2d6c453c78847")
require.Equal(t, correctHash, hash, "Hash not equal to expected hash")
}

var testInt64 = int64(987654321)
Expand Down Expand Up @@ -321,3 +324,21 @@ func FuzzHeaderExtraHash(f *testing.F) {
}
})
}

func FuzzHeaderExchangeRate(f *testing.F) {
fuzzHeaderBigIntHash(f,
func(h *Header) *big.Int { return h.exchangeRate },
func(h *Header, bi *big.Int) { h.exchangeRate = bi })
}

func FuzzHeaderQuaiToQi(f *testing.F) {
fuzzHeaderBigIntHash(f,
func(h *Header) *big.Int { return h.quaiToQi },
func(h *Header, bi *big.Int) { h.quaiToQi = bi })
}

func FuzzHeaderQiToQuai(f *testing.F) {
fuzzHeaderBigIntHash(f,
func(h *Header) *big.Int { return h.qiToQuai },
func(h *Header, bi *big.Int) { h.qiToQuai = bi })
}
2 changes: 1 addition & 1 deletion core/types/wo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func woTestData() (*WorkObject, common.Hash) {

func TestWoHash(t *testing.T) {
_, actualHash := woTestData()
expectedHash := common.HexToHash("0x637f1fddf2efea7aef3d42086d75f225c5399f2991254fa27c9930852529210b")
expectedHash := common.HexToHash("0x572273f26629ca2a02c329cd21dc3def6e1d1934465ea11fca393c7a9ce3c89b")
require.Equal(t, expectedHash, actualHash, "Hash not equal to expected hash")
}

Expand Down

0 comments on commit 5a938b7

Please sign in to comment.