Merge basecoin with tendermint_classic

This commit is contained in:
Jae Kwon
2016-03-21 15:31:25 -07:00
parent 3d8cb897b8
commit 5049c35efc
14 changed files with 789 additions and 398 deletions
+4 -4
View File
@@ -12,8 +12,8 @@ func PrivAccountFromSecret(secret string) types.PrivAccount {
privKey := crypto.GenPrivKeyEd25519FromSecret([]byte(secret))
privAccount := types.PrivAccount{
PrivKey: privKey,
PubKey: privKey.PubKey(),
Account: types.Account{
PubKey: privKey.PubKey(),
Sequence: 0,
Balance: 0,
},
@@ -22,21 +22,21 @@ func PrivAccountFromSecret(secret string) types.PrivAccount {
}
// Make `num` random accounts
func RandAccounts(num int, minAmount uint64, maxAmount uint64) []types.PrivAccount {
func RandAccounts(num int, minAmount int64, maxAmount int64) []types.PrivAccount {
privAccs := make([]types.PrivAccount, num)
for i := 0; i < num; i++ {
balance := minAmount
if maxAmount > minAmount {
balance += RandUint64() % (maxAmount - minAmount)
balance += RandInt64() % (maxAmount - minAmount)
}
privKey := crypto.GenPrivKeyEd25519()
pubKey := privKey.PubKey()
privAccs[i] = types.PrivAccount{
PrivKey: privKey,
PubKey: pubKey,
Account: types.Account{
PubKey: pubKey,
Sequence: 0,
Balance: balance,
},
+20 -18
View File
@@ -35,7 +35,7 @@ func main() {
// Get the root account
root := tests.PrivAccountFromSecret("root")
sequence := uint(0)
sequence := int(0)
// Make a bunch of PrivAccounts
privAccounts := tests.RandAccounts(1000, 1000000, 0)
privAccountSequences := make(map[string]int)
@@ -44,17 +44,18 @@ func main() {
for i := 0; i < len(privAccounts); i++ {
privAccount := privAccounts[i]
tx := &types.SendTx{
Inputs: []types.Input{
types.Input{
PubKey: root.PubKey,
Inputs: []types.TxInput{
types.TxInput{
Address: root.Account.PubKey.Address(),
PubKey: root.Account.PubKey, // TODO is this needed?
Amount: 1000002,
Sequence: sequence,
},
},
Outputs: []types.Output{
types.Output{
PubKey: privAccount.PubKey,
Amount: 1000000,
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccount.Account.PubKey.Address(),
Amount: 1000000,
},
},
}
@@ -89,22 +90,23 @@ func main() {
}
privAccountA := privAccounts[randA]
privAccountASequence := privAccountSequences[privAccountA.PubKey.KeyString()]
privAccountSequences[privAccountA.PubKey.KeyString()] = privAccountASequence + 1
privAccountASequence := privAccountSequences[privAccountA.Account.PubKey.KeyString()]
privAccountSequences[privAccountA.Account.PubKey.KeyString()] = privAccountASequence + 1
privAccountB := privAccounts[randB]
tx := &types.SendTx{
Inputs: []types.Input{
types.Input{
PubKey: privAccountA.PubKey,
Inputs: []types.TxInput{
types.TxInput{
Address: privAccountA.Account.PubKey.Address(),
PubKey: privAccountA.Account.PubKey,
Amount: 3,
Sequence: uint(privAccountASequence),
Sequence: privAccountASequence,
},
},
Outputs: []types.Output{
types.Output{
PubKey: privAccountB.PubKey,
Amount: 1,
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccountB.Account.PubKey.Address(),
Amount: 1,
},
},
}