Skip to content

Commit

Permalink
Switch test framework to Test2::V0
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrtj committed Aug 25, 2024
1 parent 1bc85a3 commit 670e5f5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 54 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ jobs:
perl -v
cpanm -v
- name: Install Test::More
if: ${{ startsWith( matrix.perl, '5.12') }}
run: |
cpanm --notest Test::More
- name: Install dependencies
run: |
cpanm --installdeps --notest .
Expand Down
2 changes: 0 additions & 2 deletions .proverc

This file was deleted.

1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ requires 'Text::QRCode' => 0;
requires 'List::Util' => '1.29';

on 'test' => sub {
requires 'Test2::V0' => 0;
requires 'Test::Script' => 0;
};

8 changes: 0 additions & 8 deletions t/01-compile.t

This file was deleted.

44 changes: 20 additions & 24 deletions t/02-generate.t → t/generate.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use v5.12;
use warnings;

use Test::More;
use Test2::V0;
use App::Bitcoin::PaperWallet;

subtest 'should generate mnemonic from fixed entropy' => sub {
Expand Down Expand Up @@ -51,29 +48,28 @@ subtest 'should generate mnemonic from random entropy' => sub {
};

subtest 'invalid network should throw exception' => sub {
local $@;
eval {
my $hash = App::Bitcoin::PaperWallet->generate(undef, 'pass', {
network => 'invalid',
});
};

like $@, qr/network invalid is not registered/, 'exception thrown ok';
my $ex = dies {
my $hash = App::Bitcoin::PaperWallet->generate(undef, 'pass', {
network => 'invalid',
});
};

like $ex, qr/network invalid is not registered/, 'exception thrown ok';
};

subtest 'valid, non-default network should not throw exception' => sub {
local $@;
my $hash;
eval {
$hash = App::Bitcoin::PaperWallet->generate(undef, 'pass', {
network => 'dogecoin',
segwit_addresses => 2,
});
};

is $@, '', 'no exception message ok';
ok defined $hash, '... and returned value is defined';
is scalar @{ $hash->{addresses} }, 3, 'generating the same number of legacy addresses as would for a segwit + compat network';
my $hash;
my $lived = lives {
$hash = App::Bitcoin::PaperWallet->generate(undef, 'pass', {
network => 'dogecoin',
segwit_addresses => 2,
compat_addresses => 3,
});
};

ok $lived, 'no exception ok';
ok defined $hash, 'returned value defined ok';
is scalar @{ $hash->{addresses} }, 5, 'generating the same number of legacy addresses as would for a segwit + compat network';
};

done_testing;
Expand Down
12 changes: 3 additions & 9 deletions t/04-script.t → t/script.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use v5.12;
use warnings;

use Test::More;
use Test2::V0;
use Test::Script;

# Keep this commented out to avoid wide character print warnings. The testing
# code seems to work properly anyway
# use utf8;
use Encode qw(encode);

use constant SCRIPT_PATH => 'bin/paper-wallet';

my $input = "entropyż\npasswordż\n";
my $input = encode 'UTF-8', "entropyż\npasswordż\n";
my $expected_seed = 'crush village tuna perfect supply movie pelican believe square neutral lens manual ship observe firm black cram brisk gallery arrest cactus tray marble over';
my $expected_address = '3HfnewBEDykB7gncDz78uzPvAvgrsNyvsy';

Expand Down
7 changes: 1 addition & 6 deletions t/03-unicode.t → t/unicode.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use v5.12;
use warnings;

use Test::More;
use Test2::V0;
use App::Bitcoin::PaperWallet;

use utf8;

my $hash = App::Bitcoin::PaperWallet->generate('another silly entropy that should never be used in a real wallet with ąść', 'ąśćź 1');

# seed should be 6f1a6e66b9c2a706a5f4c16bb0ea34a54577bda27d7a0900be9e8afc952e731e
Expand Down

0 comments on commit 670e5f5

Please sign in to comment.