create fixtures for michael

pull/945/head
Minh Doan 6 years ago committed by Minh Doan
parent 2b5fa476bb
commit d39f562066
  1. 69
      test/txgen/main.go
  2. 152
      test/txgen/tx.json

@ -21,7 +21,33 @@ var (
shardID = flag.Int64("shard_id", 0, "shard id")
)
func generateTxnHarmony(PrivateKeyFrom string, ToAddress string, shardID uint32, amount int64) *types.Transaction {
// DeployAccount is the accounts used for development.
type DeployAccount struct {
Address string
Private string
Public string
}
// DemoAccounts is the accounts used for lottery demo.
var DemoAccounts = [...]DeployAccount{
{Address: "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723", Private: "27978f895b11d9c737e1ab1623fde722c04b4f9ccb4ab776bf15932cc72d7c66", Public: "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723"},
{Address: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E", Private: "371cb68abe6a6101ac88603fc847e0c013a834253acee5315884d2c4e387ebca", Public: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E"},
{Address: "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33", Private: "3f8af52063c6648be37d4b33559f784feb16d8e5ffaccf082b3657ea35b05977", Public: "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33"},
{Address: "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52", Private: "df77927961152e6a080ac299e7af2135fc0fb02eb044d0d7bbb1e8c5ad523809", Public: "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52"},
{Address: "0x67957240b6eB045E17B47dcE98102f09aaC03435", Private: "fcff43741ad2dd0b232efb159dc47736bbb16f11a79aaeec39b388d06f91116d", Public: "0x67957240b6eB045E17B47dcE98102f09aaC03435"},
{Address: "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558", Private: "916d3d78b7f413452434e89f9c1f1d136995ef02d7dc8038e84cc9cef4a02b96", Public: "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558"},
{Address: "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B", Private: "f5967bd87fd2b9dbf51855a2a75ef0a811c84953b3b300ffe90c430a5c856303", Public: "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B"},
{Address: "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC", Private: "f02f7b3bb5aa03aa97f9e030020dd9ca306b209742fafe018104a3207a70a3c9", Public: "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC"},
{Address: "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138", Private: "0436864cc15772448f88dd40554592ff6c91a6c1a389d965ad26ee143db1234d", Public: "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138"},
{Address: "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281", Private: "dea956e530073ab23d9cae704f5d068482b1977c3173c9efd697c48a7fd3ce83", Public: "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281"},
{Address: "0x46C61d50874A7A06D29FF89a710AbBD0856265be", Private: "af539d4ace07a9f601a8d3a6ca6f914d5a9fabe09cfe7d62ebc2348fc95f03a4", Public: "0x46C61d50874A7A06D29FF89a710AbBD0856265be"},
{Address: "0xfE9BABE6904C28E31971337738FBCBAF8c72873e", Private: "7d24797eeba0cdac9bf943f0d82c4b18eb206108d6e1b7f610471594c0c94306", Public: "0xfE9BABE6904C28E31971337738FBCBAF8c72873e"},
{Address: "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250", Private: "4fa2fecce1becfaf7e5fba5394caacb318333b04071462b5ca850ee5a406dcfe", Public: "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250"},
{Address: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8", Private: "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f", Public: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8"},
{Address: "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647", Private: "bf29f6a33b2c24a8b5182ef44cc35ce87534ef827c8dfbc1e6bb536aa52f8563", Public: "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647"},
}
func generateTxnHarmony(PrivateKeyFrom string, ToAddress string, shardID uint32, amount int64) (*types.Transaction, *types.Transaction) {
privateKey, _ := crypto.HexToECDSA(PrivateKeyFrom)
nonce := uint64(0)
value := big.NewInt(1000000000000000000 * amount)
@ -29,26 +55,51 @@ func generateTxnHarmony(PrivateKeyFrom string, ToAddress string, shardID uint32,
toAddress := common.HexToAddress(ToAddress)
var data []byte
signedTx, _ := types.SignTx(types.NewTransaction(nonce,
unsignedTx := types.NewTransaction(nonce,
toAddress,
shardID,
value,
gasLimit, nil, data),
gasLimit, nil, data)
signedTx, _ := types.SignTx(
unsignedTx,
types.HomesteadSigner{},
privateKey)
privateKey,
)
fmt.Println("signedTx.Hash().Hex(): ", signedTx.Hash().Hex())
// fmt.Println("signedTx.Hash().Hex(): ", signedTx.Hash().Hex())
// ts := types.Transactions{signedTx}
// rawTxBytes := ts.GetRlp(0)
// fmt.Println(rawTxBytes)
// rawTxHex := hex.EncodeToString(rawTxBytes)
// fmt.Println("serialized: ", rawTxHex)
return unsignedTx, signedTx
}
ts := types.Transactions{signedTx}
func serialized(tx *types.Transaction) string {
ts := types.Transactions{tx}
rawTxBytes := ts.GetRlp(0)
fmt.Println(rawTxBytes)
rawTxHex := hex.EncodeToString(rawTxBytes)
fmt.Println("serialized: ", rawTxHex)
return signedTx
return rawTxHex
}
func main() {
flag.Parse()
generateTxnHarmony(*fromPrivateKey, *toAddress, uint32(*shardID), 1)
for i := 0; i < len(DemoAccounts); i++ {
j := (i + 1) % len(DemoAccounts)
shardID := i % 4
unsignedTx, signedTx := generateTxnHarmony(DemoAccounts[i].Private, DemoAccounts[j].Address, uint32(shardID), int64(shardID))
fmt.Printf(
"{ \"fromPrivate\": \"%s\", \"toAddress\": \"%s\", \"shardID\": %d, \"amount\": %d, \"nonce\": 0, \"gasLimit\": 21000, \"unsignedTx\": \"%s\", \"signedTx\": \"%s\" },\n",
DemoAccounts[i].Private,
DemoAccounts[j].Address,
shardID,
shardID,
serialized(unsignedTx),
serialized(signedTx),
)
}
}

@ -0,0 +1,152 @@
[
{
"fromPrivate": "27978f895b11d9c737e1ab1623fde722c04b4f9ccb4ab776bf15932cc72d7c66",
"toAddress": "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E",
"shardID": 0,
"amount": 0,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e08080825208809410a02a0a6e95a676ae23e2db04bea3d1b8b7ca2e8080808080",
"signedTx": "f8608080825208809410a02a0a6e95a676ae23e2db04bea3d1b8b7ca2e80801ca0da715d547791818390df18f6c1baf54d4369eba03f578f5f21199c7933d5a23ca06de1086983eb0fe1690e85e7df1108473699c81721376ba67fceaf78a4a2cdf2"
},
{
"fromPrivate": "371cb68abe6a6101ac88603fc847e0c013a834253acee5315884d2c4e387ebca",
"toAddress": "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33",
"shardID": 1,
"amount": 1,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520801943e881f6c36a3a14a2d1816b0a5471d1cabb16f33880de0b6b3a764000080808080",
"signedTx": "f868808082520801943e881f6c36a3a14a2d1816b0a5471d1cabb16f33880de0b6b3a7640000801ba0b43bcf2dd258777aa5ff536e268b5e345bf81191ee3278da099a97e63b841399a0728203815bf7d6d3bff2a52ea6904e1d8e26900284ad7a0d047b36d79fc7d751"
},
{
"fromPrivate": "3f8af52063c6648be37d4b33559f784feb16d8e5ffaccf082b3657ea35b05977",
"toAddress": "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52",
"shardID": 2,
"amount": 2,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520802949d72989b68777a1f3ffd6f1db079f1928373ee52881bc16d674ec8000080808080",
"signedTx": "f868808082520802949d72989b68777a1f3ffd6f1db079f1928373ee52881bc16d674ec80000801ca0da9f6416bc0d693966499c0765efd96aa44185dcb580cffcd8f3d6afd700f729a07b7369368d11db117bc287b0eb354dee12d4aa9ada62f96009c4a2a2ea832641"
},
{
"fromPrivate": "df77927961152e6a080ac299e7af2135fc0fb02eb044d0d7bbb1e8c5ad523809",
"toAddress": "0x67957240b6eB045E17B47dcE98102f09aaC03435",
"shardID": 3,
"amount": 3,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e88080825208039467957240b6eb045e17b47dce98102f09aac034358829a2241af62c000080808080",
"signedTx": "f8688080825208039467957240b6eb045e17b47dce98102f09aac034358829a2241af62c0000801ba054f1b3ad63a950b3c8bfd2f70e9054a09437517332b501452f8c8519a2eb9a4da035a5f2a67795ddd81d2bf575aa6ed14266e716c5802529ced04c2e42240ec6b1"
},
{
"fromPrivate": "fcff43741ad2dd0b232efb159dc47736bbb16f11a79aaeec39b388d06f91116d",
"toAddress": "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558",
"shardID": 0,
"amount": 0,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e080808252088094f70fbdb1ad002badf19024785b1a4bf6f841f5588080808080",
"signedTx": "f86080808252088094f70fbdb1ad002badf19024785b1a4bf6f841f55880801ba03c8a0008ddb02551075b9ba2b92c6813e4d39a50487e608db3535290b11c1cb1a02696d31fd9aeace1065c4f878b7ceeda3352ce05bb32d59b36a5f7440a1eb8bc"
},
{
"fromPrivate": "916d3d78b7f413452434e89f9c1f1d136995ef02d7dc8038e84cc9cef4a02b96",
"toAddress": "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B",
"shardID": 1,
"amount": 1,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520801943f1a559be93c9456ca75712535fd522f5ec22c6b880de0b6b3a764000080808080",
"signedTx": "f868808082520801943f1a559be93c9456ca75712535fd522f5ec22c6b880de0b6b3a7640000801ba09c86f5b54bb6b520781b107840eccba443084fb702056f67bde36010a4571d81a0532c1408096cd02e740b6c4793a89500f594f3647d0b8d6bf24c2a9c3c38f8bc"
},
{
"fromPrivate": "f5967bd87fd2b9dbf51855a2a75ef0a811c84953b3b300ffe90c430a5c856303",
"toAddress": "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC",
"shardID": 2,
"amount": 2,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e880808252080294edd257b4e0f5e7d632c737f4277e93b64dc268fc881bc16d674ec8000080808080",
"signedTx": "f86880808252080294edd257b4e0f5e7d632c737f4277e93b64dc268fc881bc16d674ec80000801ba0b5ef37d8a01ba077289d6333f48a241845aeaed0f2ed8e863f34ac3828c2d99da043601572bd0e559fd36fd58d5bbd667e1f0788ee3930c1fe9194a1035b15bef2"
},
{
"fromPrivate": "f02f7b3bb5aa03aa97f9e030020dd9ca306b209742fafe018104a3207a70a3c9",
"toAddress": "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138",
"shardID": 3,
"amount": 3,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e88080825208039466a74477fc1dd0f4924ed943c1d2f1dece3ab1388829a2241af62c000080808080",
"signedTx": "f8688080825208039466a74477fc1dd0f4924ed943c1d2f1dece3ab1388829a2241af62c0000801ba011f5f18be759f168332f8913adec2f7a069658bb0f8a236dbee6cba9c4450d12a054dacc2be540c2779acabeced87abffaf0fe6a74cdbb75c6003d1cadbc89f11e"
},
{
"fromPrivate": "0436864cc15772448f88dd40554592ff6c91a6c1a389d965ad26ee143db1234d",
"toAddress": "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281",
"shardID": 0,
"amount": 0,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e08080825208809404178cdbce3a9ff9ea385777afc4b78b3e7452818080808080",
"signedTx": "f8608080825208809404178cdbce3a9ff9ea385777afc4b78b3e74528180801ba08a19a111a85a018acb4c6edd7ddda0acdd0b7de0207eb93f7adad8cec59479d9a00d8bd7eea1b0c96c951a2e931ae6b0588d24f12d588f80a5d647e4c082413671"
},
{
"fromPrivate": "dea956e530073ab23d9cae704f5d068482b1977c3173c9efd697c48a7fd3ce83",
"toAddress": "0x46C61d50874A7A06D29FF89a710AbBD0856265be",
"shardID": 1,
"amount": 1,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e88080825208019446c61d50874a7a06d29ff89a710abbd0856265be880de0b6b3a764000080808080",
"signedTx": "f8688080825208019446c61d50874a7a06d29ff89a710abbd0856265be880de0b6b3a7640000801ba0c2c77b032a4794c9603d60bb6371ac729403efdf88b595aac699d4e208c1a453a07f55088f81c372857d95a9dec8b0828e572bca56017e3a35ecd3c3f9143a12f4"
},
{
"fromPrivate": "af539d4ace07a9f601a8d3a6ca6f914d5a9fabe09cfe7d62ebc2348fc95f03a4",
"toAddress": "0xfE9BABE6904C28E31971337738FBCBAF8c72873e",
"shardID": 2,
"amount": 2,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e880808252080294fe9babe6904c28e31971337738fbcbaf8c72873e881bc16d674ec8000080808080",
"signedTx": "f86880808252080294fe9babe6904c28e31971337738fbcbaf8c72873e881bc16d674ec80000801ba0d94f56e5e3eb497b0cb84035401e4ab0abea3ac35efb33ec0dbd80c1b82f5df5a0425834db5fee85ae7f783b691b583a2bc5ee54814d628f3e67f743a26157a0a8"
},
{
"fromPrivate": "7d24797eeba0cdac9bf943f0d82c4b18eb206108d6e1b7f610471594c0c94306",
"toAddress": "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250",
"shardID": 3,
"amount": 3,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520803943f78622de8d8f87eaa0e8b28c2851e2450e912508829a2241af62c000080808080",
"signedTx": "f868808082520803943f78622de8d8f87eaa0e8b28c2851e2450e912508829a2241af62c0000801ca0556df9dda0efa782e26e19a3a5026cf5c2f3a0c17fd17a3ba6b91ffcd16dc312a01a406d707b2702551d2ef6fa7f157a956c5fdbbdd0438cf881a84256e2f32e84"
},
{
"fromPrivate": "4fa2fecce1becfaf7e5fba5394caacb318333b04071462b5ca850ee5a406dcfe",
"toAddress": "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8",
"shardID": 0,
"amount": 0,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e080808252088094d2cb501b40d3a9a013a38267a4d2a4cf6bd2caa88080808080",
"signedTx": "f86080808252088094d2cb501b40d3a9a013a38267a4d2a4cf6bd2caa880801ca01df595c0ff3ae65408e206436ea0b6b58ecb3338c60c96adc6e64e7d0833569ba03a6ae5835ed4e9dcc88375e59e8306c8be49a8424f4137d97cc71cf29bb9333d"
},
{
"fromPrivate": "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f",
"toAddress": "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647",
"shardID": 1,
"amount": 1,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520801942676e6dd2d7618be14cb4c18a355c81bf7aac647880de0b6b3a764000080808080",
"signedTx": "f868808082520801942676e6dd2d7618be14cb4c18a355c81bf7aac647880de0b6b3a7640000801ca06c20c3a0862f59644bbed846a610db4a98a52901ba34c4f0ba722a8d5144a44fa0121020d3704926c479b7c12f68897f1d6ce0d53b96fd0739584af78aca4b2e2b"
},
{
"fromPrivate": "bf29f6a33b2c24a8b5182ef44cc35ce87534ef827c8dfbc1e6bb536aa52f8563",
"toAddress": "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723",
"shardID": 2,
"amount": 2,
"nonce": 0,
"gasLimit": 21000,
"unsignedTx": "e8808082520802941a3e7a44ee21101d7d64fbf29b0f6f1fc295f723881bc16d674ec8000080808080",
"signedTx": "f868808082520802941a3e7a44ee21101d7d64fbf29b0f6f1fc295f723881bc16d674ec80000801ba0fdfdb231fd424f9ed1a70f3810a1bf1b2208e0969e403b328631146034d2ae0aa043170676fe14fbfdd6ee772d4ad6feac931921cac2c3b31a4c7708ced5518560"
}
]
Loading…
Cancel
Save