From f1cf640261803efc0c11df62e2807448cac0bb76 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 11 Sep 2024 15:44:58 +0300 Subject: [PATCH] test for decoding output that matches signature --- test/abi/type_decoder_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/abi/type_decoder_test.exs b/test/abi/type_decoder_test.exs index 4bd7615..a68fe97 100644 --- a/test/abi/type_decoder_test.exs +++ b/test/abi/type_decoder_test.exs @@ -757,6 +757,22 @@ defmodule ABI.TypeDecoderTest do TypeDecoder.decode(data, selector) end end + + test "decodes output that matches signature" do + selector = %FunctionSelector{ + function: "baz", + method_id: <<199, 158, 242, 32>>, + types: [ + {:int, 8}, + {:int, 256} + ], + returns: [{:bytes, 4}] + } + + result_to_decode = TypeEncoder.encode([selector.method_id], [{:bytes, 4}]) + + assert TypeDecoder.decode(result_to_decode, selector, :output) == [selector.method_id] + end end describe "with examples from solidity docs" do