WIP
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
|
||||
mods() ->
|
||||
#{"base64" => fun base64/0,
|
||||
"base58" => fun base58/0}.
|
||||
"base58" => fun base58/0,
|
||||
"rlp" => fun rlp/0}.
|
||||
|
||||
|
||||
-spec start(ArgV) -> ok
|
||||
@@ -99,8 +100,8 @@ base58() ->
|
||||
ok = filelib:ensure_dir(TestFile),
|
||||
ok = file:write_file(TestFile, rand:bytes(rand:uniform(5000))),
|
||||
{ok, Bytes} = file:read_file(TestFile),
|
||||
Base64 = base58:binary_to_base58(Bytes),
|
||||
ok = file:write_file(ConvFile, Base64),
|
||||
Base58 = base58:binary_to_base58(Bytes),
|
||||
ok = file:write_file(ConvFile, Base58),
|
||||
Run = unicode:characters_to_list(["bin/run base58 ", temp_dir()]),
|
||||
[JavaEncPath, JavaDecPath] = string:split(os:cmd(Run), " "),
|
||||
{ok, E_Enc_Bytes} = file:read_file(ConvFile),
|
||||
@@ -112,3 +113,23 @@ base58() ->
|
||||
E_BinHash = crypto:hash(sha512, E_Dec_Bytes),
|
||||
J_BinHash = crypto:hash(sha512, J_Dec_Bytes),
|
||||
E_Hash =:= J_Hash andalso E_BinHash =:= J_BinHash.
|
||||
|
||||
rlp() ->
|
||||
Anchor = <<"I thought what I'd do was, I'd pretend I was one of those deaf-mutes.">>,
|
||||
Data =
|
||||
[rand:bytes(rand:uniform(20)),
|
||||
[rand:bytes(rand:uniform(20)),
|
||||
Anchor,
|
||||
rand:bytes(rand:uniform(20)),
|
||||
rand:bytes(rand:uniform(5000))],
|
||||
rand:bytes(rand:uniform(2000))],
|
||||
RLP = gmser_rlp:encode(Data),
|
||||
RLP_File = filename:join(temp_dir(), "rlp.test"),
|
||||
ok = file:write_file(RLP_File, RLP),
|
||||
Run = unicode:characters_to_list(["bin/run rlp ", temp_dir()]),
|
||||
[Found, JavaEncPath] = string:split(os:cmd(Run), " "),
|
||||
{ok, E_Enc_Bytes} = file:read_file(RLP_File),
|
||||
{ok, J_Enc_Bytes} = file:read_file(JavaEncPath),
|
||||
E_Hash = crypto:hash(sha512, E_Enc_Bytes),
|
||||
J_Hash = crypto:hash(sha512, J_Enc_Bytes),
|
||||
E_Hash =:= J_Hash andalso Found =:= Anchor.
|
||||
|
||||
Reference in New Issue
Block a user