|
| 1 | +// Copyright 2025 the libevm authors. |
| 2 | +// |
| 3 | +// The libevm additions to go-ethereum are free software: you can redistribute |
| 4 | +// them and/or modify them under the terms of the GNU Lesser General Public License |
| 5 | +// as published by the Free Software Foundation, either version 3 of the License, |
| 6 | +// or (at your option) any later version. |
| 7 | +// |
| 8 | +// The libevm additions are distributed in the hope that they will be useful, |
| 9 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
| 11 | +// General Public License for more details. |
| 12 | +// |
| 13 | +// You should have received a copy of the GNU Lesser General Public License |
| 14 | +// along with the go-ethereum library. If not, see |
| 15 | +// <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +package trie |
| 18 | + |
| 19 | +import ( |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/stretchr/testify/require" |
| 23 | + |
| 24 | + "github.com/ava-labs/libevm/common" |
| 25 | +) |
| 26 | + |
| 27 | +func TestRangeProofKeysWithDifferentLengths(t *testing.T) { |
| 28 | + var ( |
| 29 | + root = common.HexToHash("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") |
| 30 | + start = common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000000") |
| 31 | + keys = [][]byte{ |
| 32 | + common.Hex2Bytes("1000000000000000000000000000000"), |
| 33 | + common.Hex2Bytes("1000000000000000000000000000000000000000000000000000000000000000"), |
| 34 | + } |
| 35 | + values = [][]byte{ |
| 36 | + common.Hex2Bytes("02"), |
| 37 | + common.Hex2Bytes("03"), |
| 38 | + } |
| 39 | + ) |
| 40 | + _, err := VerifyRangeProof( |
| 41 | + root, |
| 42 | + start, |
| 43 | + keys, |
| 44 | + values, |
| 45 | + nil, // force it to use stacktrie |
| 46 | + ) |
| 47 | + require.ErrorIs(t, err, errKeysHaveDifferentLengths) |
| 48 | +} |
0 commit comments