Skip to content

Commit

Permalink
add key test for receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitprincess committed Oct 11, 2023
1 parent 4dfbcaf commit 33c4fa2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion internal/schema/key_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
package schema

import (
"math"
"testing"

"github.com/aergoio/aergo/v2/types"
"github.com/stretchr/testify/assert"
)

// TODO
func TestKeyReceipts(t *testing.T) {

for _, test := range []struct {
blockHash []byte
blockNo types.BlockNo
expectKey []byte
}{
{nil, 0, []byte{byte('r'), 0, 0, 0, 0, 0, 0, 0, 0}},
{nil, 1, []byte{byte('r'), 1, 0, 0, 0, 0, 0, 0, 0}},
{nil, 255, []byte{byte('r'), 255, 0, 0, 0, 0, 0, 0, 0}},
{nil, math.MaxUint64, []byte{byte('r'), 255, 255, 255, 255, 255, 255, 255, 255}},
{[]byte{1, 2, 3, 4}, 0, []byte{byte('r'), 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0}},
{[]byte{144, 75, 132, 157, 195, 199, 41, 233, 24, 89, 183, 252, 80, 151, 5, 244, 83, 64, 39, 204, 84, 37, 182, 61, 72, 248, 192, 223, 59, 216, 108, 240}, 0, []byte{byte('r'), 144, 75, 132, 157, 195, 199, 41, 233, 24, 89, 183, 252, 80, 151, 5, 244, 83, 64, 39, 204, 84, 37, 182, 61, 72, 248, 192, 223, 59, 216, 108, 240, 0, 0, 0, 0, 0, 0, 0, 0}},
} {
key := KeyReceipts(test.blockHash, test.blockNo)
assert.Equal(t, test.expectKey, key, "TestKeyReceipts(%v, %v)", test.blockHash, test.blockNo)
}
}

// raft
Expand Down

0 comments on commit 33c4fa2

Please sign in to comment.