github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/native/native_llr_test.go (about) 1 package native 2 3 import ( 4 "encoding/hex" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 9 "github.com/unicornultrafoundation/go-helios/hash" 10 ) 11 12 var test_block_votes = LlrBlockVotes{ 13 Start: 9000, 14 Epoch: 342, 15 Votes: []hash.Hash{ 16 hash.Of(nil), 17 }, 18 } 19 var test_signed_event_locator = SignedEventLocator{ 20 Locator: EventLocator{ 21 BaseHash: hash.Of(nil), 22 NetForkID: 1, 23 Epoch: 42, 24 Seq: 9_000_000, 25 Lamport: 142, 26 Creator: 242, 27 PayloadHash: hash.Of(nil), 28 }, 29 Sig: [64]byte{}, 30 } 31 var test_txs_and_misbehaviour_proofs_hash = hash.Of(nil) 32 var test_epoch_vote_hash = hash.Of(nil) 33 var test_block_votes_hash = hash.Of(nil) 34 35 var test_llr_signed_block_votes = LlrSignedBlockVotes{ 36 Signed: test_signed_event_locator, 37 TxsAndMisbehaviourProofsHash: test_txs_and_misbehaviour_proofs_hash, 38 EpochVoteHash: test_epoch_vote_hash, 39 Val: test_block_votes, 40 } 41 var test_llr_signed_epoch_vote = LlrSignedEpochVote{ 42 Signed: test_signed_event_locator, 43 TxsAndMisbehaviourProofsHash: test_txs_and_misbehaviour_proofs_hash, 44 BlockVotesHash: test_block_votes_hash, 45 Val: LlrEpochVote{ 46 Epoch: test_signed_event_locator.Locator.Epoch, 47 Vote: test_epoch_vote_hash, 48 }, 49 } 50 51 func TestLlrBlockVotesHashing(t *testing.T) { 52 require.Equal(t, "7db20066868c07236a5f5641eac6a1ddb5cd1dc1602252a3672758056b4562a8", hex.EncodeToString(test_block_votes.Hash().Bytes())) 53 } 54 55 func TestLlrSignedBlockVotesHashing(t *testing.T) { 56 require.Equal(t, "26b5c58d72b48f2ce40f5e18df4dda66f644839d00611b9a7812e8f9f708f143", hex.EncodeToString(test_llr_signed_block_votes.CalcPayloadHash().Bytes())) 57 } 58 59 func TestLlrSignedEpochVoteHashing(t *testing.T) { 60 require.Equal(t, "e6c5f9d9e45f04b286c8361d8b5851f7ee16538f408ad86afa4d2b2612a10a75", hex.EncodeToString(test_llr_signed_epoch_vote.CalcPayloadHash().Bytes())) 61 }