Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

deflap tests #164

Merged
merged 11 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{<<"base32">>,{pkg,<<"base32">>,<<"0.1.0">>},3},
{<<"blockchain">>,
{git,"[email protected]:helium/blockchain-core.git",
{ref,"b0bd97938ae06fe8915c207cc5352f6bbae1d5f6"}},
{ref,"898acb718cbec21be43982143c4925d3edf4ff76"}},
0},
{<<"clique">>,
{git,"https://github.com/helium/clique.git",
Expand Down
20 changes: 12 additions & 8 deletions src/cli/miner_cli_genesis.erl
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ create(OldGenesisFile, PubKeyB58, ProofB58, Addrs, N, Curve) ->
BinPub = libp2p_crypto:b58_to_bin(PubKeyB58),
Proof = base58:base58_to_binary(ProofB58),

VarTxn = blockchain_txn_vars_v1:new(make_vars(), <<>>, 1, #{master_key => BinPub,
key_proof => Proof}),
VarTxn = blockchain_txn_vars_v1:new(make_vars(), 1, #{master_key => BinPub}),
VarTxn1 = blockchain_txn_vars_v1:key_proof(VarTxn, Proof),

OldSecurities = case proplists:get_value(securities, Config) of
undefined -> [];
Expand Down Expand Up @@ -132,7 +132,7 @@ create(OldGenesisFile, PubKeyB58, ProofB58, Addrs, N, Curve) ->

OldGenesisTransactions = OldAccounts ++ OldGateways ++ OldSecurities ++ OldDCs,
Addresses = [libp2p_crypto:p2p_to_pubkey_bin(Addr) || Addr <- string:split(Addrs, ",", all)],
miner_consensus_mgr:initial_dkg(OldGenesisTransactions ++ [VarTxn], Addresses, N, Curve),
miner_consensus_mgr:initial_dkg(OldGenesisTransactions ++ [VarTxn1], Addresses, N, Curve),
[clique_status:text("ok")];
{error, Reason} ->
[clique_status:text(io_lib:format("~p", [Reason]))]
Expand Down Expand Up @@ -170,8 +170,8 @@ forge(PubKeyB58, ProofB58, Addrs, N, Curve) ->
BinPub = libp2p_crypto:b58_to_bin(PubKeyB58),
Proof = base58:base58_to_binary(ProofB58),

VarTxn = blockchain_txn_vars_v1:new(make_vars(), <<>>, 1, #{master_key => BinPub,
key_proof => Proof}),
VarTxn = blockchain_txn_vars_v1:new(make_vars(), 1, #{master_key => BinPub}),
VarTxn1 = blockchain_txn_vars_v1:key_proof(VarTxn, Proof),

Addresses = [libp2p_crypto:p2p_to_pubkey_bin(Addr) || Addr <- string:split(Addrs, ",", all)],
InitialPaymentTransactions = [ blockchain_txn_coinbase_v1:new(Addr, 500000000) || Addr <- Addresses],
Expand All @@ -182,7 +182,7 @@ forge(PubKeyB58, ProofB58, Addrs, N, Curve) ->
%% NOTE: This is mostly for locally testing run.sh so we have nodes added as gateways in the genesis block
InitialGatewayTransactions = [blockchain_txn_gen_gateway_v1:new(Addr, Addr, 16#8c283475d4e89ff, 0)
|| Addr <- Addresses ],
miner_consensus_mgr:initial_dkg([VarTxn] ++
miner_consensus_mgr:initial_dkg([VarTxn1] ++
InitialPaymentTransactions ++
InitialGatewayTransactions ++
InitialSecurityTransactions ++
Expand Down Expand Up @@ -296,9 +296,13 @@ genesis_proof(["genesis", "proof", PrivKeyB58], [], []) ->
PrivKeyBin = base58:base58_to_binary(PrivKeyB58),
#{secret := Priv, public := Pub} = libp2p_crypto:keys_from_bin(PrivKeyBin),
Vars = make_vars(),
KeyProof = blockchain_txn_vars_v1:create_proof(Priv, Vars),

BinPub = libp2p_crypto:pubkey_to_bin(Pub),
Txn = blockchain_txn_vars_v1:new(Vars, 1, #{master_key => BinPub}),
Proof = blockchain_txn_vars_v1:create_proof(Priv, Txn),

[clique_status:text(io_lib:format("Proof:~n~s~nPubKey:~n~s",
[base58:binary_to_base58(KeyProof),
[base58:binary_to_base58(Proof),
libp2p_crypto:pubkey_to_b58(Pub)]))];
genesis_proof(_, [], []) ->
usage.
Expand Down
Loading