-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update encoder to support more types
- Loading branch information
Showing
2 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
<?php | ||
|
||
use Brick\Math\BigInteger; | ||
use Superciety\ElrondSdk\Domain\Address; | ||
use Superciety\ElrondSdk\Utils\Encoder; | ||
|
||
it('toHex - encodes strings into hex', fn () => expect(Encoder::toHex('anything'))->toBe('616e797468696e67')); | ||
|
||
it('toHex - encodes single-byte into into hex', fn () => expect(Encoder::toHex(2))->toBe('02')); | ||
it('toHex - encodes single-byte into hex', fn () => expect(Encoder::toHex(2))->toBe('02')); | ||
|
||
it('toHex - encodes multi-byte into into hex', fn () => expect(Encoder::toHex(257))->toBe('0101')); | ||
it('toHex - encodes multi-byte into hex', fn () => expect(Encoder::toHex(257))->toBe('0101')); | ||
|
||
it('toHex - encodes an address string into into hex', fn () => expect(Encoder::toHex('erd18fswpz2r2q3p40jlewkt9u7d46lvrukdn8j09tppza75efv0jz8s2lc68r'))->toBe('3a60e0894350221abe5fcbacb2f3cdaebec1f2cd99e4f2ac21177d4ca58f908f')); | ||
it('toHex - encodes an address into hex', fn () => expect(Encoder::toHex(Address::fromBech32('erd18fswpz2r2q3p40jlewkt9u7d46lvrukdn8j09tppza75efv0jz8s2lc68r')))->toBe('3a60e0894350221abe5fcbacb2f3cdaebec1f2cd99e4f2ac21177d4ca58f908f')); | ||
|
||
it('toHex - encodes an address string into hex', fn () => expect(Encoder::toHex('erd18fswpz2r2q3p40jlewkt9u7d46lvrukdn8j09tppza75efv0jz8s2lc68r'))->toBe('3a60e0894350221abe5fcbacb2f3cdaebec1f2cd99e4f2ac21177d4ca58f908f')); | ||
|
||
it('toHex - encodes an bigint into hex', fn () => expect(Encoder::toHex(BigInteger::of('25000000000000000000')))->toBe('015af1d78b58c40000')); |