Skip to content

Commit

Permalink
chore: replace /common/abi module (#1127)
Browse files Browse the repository at this point in the history
* chore: replace /abi module

Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>

* test: add tests

Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>

* test: add tests for encoding

Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>

* chore: address PR feedback

Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>

---------

Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
  • Loading branch information
0xivanov authored Nov 8, 2024
1 parent 457eb5e commit 2c22da8
Show file tree
Hide file tree
Showing 15 changed files with 3,327 additions and 30 deletions.
433 changes: 433 additions & 0 deletions abi.go

Large diffs are not rendered by default.

422 changes: 422 additions & 0 deletions abi_decode.go

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions abi_decode_unit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build all || unit
// +build all unit

package hedera

/*-
*
* Hedera Go SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestDecodeBytesBound(t *testing.T) {
typ, _ := NewType("tuple(string)")
decodeTuple(typ, nil) // it should not panic
}

func TestDecodeDynamicLengthOutOfBounds(t *testing.T) {
input := []byte("00000000000000000000000000000000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 00000000000000000000000000")
typ, _ := NewType("tuple(bytes32, bytes, bytes)")

_, err := Decode(typ, input)
require.Error(t, err)
}
Loading

0 comments on commit 2c22da8

Please sign in to comment.