MCPcopy Index your code
hub / github.com/chain/Core / setup

Method setup

perf/UtxoReservation.java:49–103  ·  view source on GitHub ↗
(Client client)

Source from the content-addressed store, hash-verified

47 // setup issues an asset into a couple of accounts at
48 // at several denominations.
49 static void setup(Client client) throws Exception {
50 MockHsm.Key centralBankIssuerKey = MockHsm.Key.create(client);
51 MockHsm.Key aliceAccountKey = MockHsm.Key.create(client);
52 MockHsm.Key bobAccountKey = MockHsm.Key.create(client);
53 loadKeys(client);
54
55 Asset currency =
56 new Asset.Builder()
57 .setAlias("currency")
58 .addRootXpub(centralBankIssuerKey.xpub)
59 .setQuorum(1)
60 .create(client);
61
62 Account alice =
63 new Account.Builder()
64 .setAlias("alice")
65 .addRootXpub(aliceAccountKey.xpub)
66 .setQuorum(1)
67 .create(client);
68
69 Account bob =
70 new Account.Builder()
71 .setAlias("bob")
72 .addRootXpub(bobAccountKey.xpub)
73 .setQuorum(1)
74 .create(client);
75
76 // Issue some currency to Alice & Bob at several amounts per utxos.
77 Transaction.Builder builder =
78 new Transaction.Builder()
79 .addAction(
80 new Transaction.Action.Issue()
81 .setAssetId(currency.id)
82 .setAmount(2 * totalPerAccount()));
83
84 for (int i = 0; i < utxoDenominations; i++) {
85 long denominationAmount = (long) Math.pow(10, i);
86 for (int j = 0; j < utxosPerDenomination; j++) {
87 builder
88 .addAction(
89 new Transaction.Action.ControlWithAccount()
90 .setAssetId(currency.id)
91 .setAmount(denominationAmount)
92 .setAccountId(alice.id))
93 .addAction(
94 new Transaction.Action.ControlWithAccount()
95 .setAssetId(currency.id)
96 .setAmount(denominationAmount)
97 .setAccountId(bob.id));
98 }
99 }
100 Transaction.Template template = builder.build(client);
101 Transaction.Template signedTemplate = HsmSigner.sign(template);
102 Transaction.SubmitResponse tx = Transaction.submit(client, signedTemplate, "confirmed");
103 }
104
105 static void transact(final Client client) throws Exception {
106 loadKeys(client);

Callers 1

mainMethod · 0.95

Calls 13

loadKeysMethod · 0.95
totalPerAccountMethod · 0.95
signMethod · 0.95
submitMethod · 0.95
addActionMethod · 0.80
createMethod · 0.65
setQuorumMethod · 0.45
addRootXpubMethod · 0.45
setAliasMethod · 0.45
setAmountMethod · 0.45
setAssetIdMethod · 0.45
setAccountIdMethod · 0.45

Tested by

no test coverage detected