Blockchain-Ethereum
view release on metacpan or search on metacpan
t/ABI/array.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Blockchain::Ethereum::ABI::Encoder;
use Blockchain::Ethereum::ABI::Decoder;
subtest "Dynamic" => sub {
my $encoder = Blockchain::Ethereum::ABI::Encoder->new;
my $addresses = [
'0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000001',
'0x0000000000000000000000000000000000000002', '0x0000000000000000000000000000000000000003',
'0x0000000000000000000000000000000000000004', '0x0000000000000000000000000000000000000005',
'0x0000000000000000000000000000000000000006', '0x0000000000000000000000000000000000000007',
'0x0000000000000000000000000000000000000008', '0x0000000000000000000000000000000000000009',
'0x0000000000000000000000000000000000000010', '0x0000000000000000000000000000000000000011',
'0x0000000000000000000000000000000000000012', '0x0000000000000000000000000000000000000013',
'0x0000000000000000000000000000000000000014', '0x0000000000000000000000000000000000000015',
'0x0000000000000000000000000000000000000016', '0x0000000000000000000000000000000000000017',
];
$encoder->function('foo')->append('address[]' => $addresses);
my $encoded = $encoder->encode;
my $encoded_expected =
'0x13cb49d4000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
is $encoded, $encoded_expected;
my $decoder = Blockchain::Ethereum::ABI::Decoder->new;
my $decoded = $decoder->append('address[]')->decode(substr $encoded_expected, 10);
is_deeply $decoded->[0], $addresses;
};
done_testing;
( run in 0.586 second using v1.01-cache-2.11-cpan-39bf76dae61 )