Skip to content

Commit

Permalink
update test net and deposit guide
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed May 13, 2024
1 parent 3dc1a3c commit 4cacd2d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,41 @@ This will set up a minimum local test net, with all nodes in a single device.

```
$ mixin setuptestnet
=>
network: 331c1956ffb45db8a61d30a2a16e3eb0a263b844a6781253acaa07dc4ad555a8
custodian: XINVo9oZLCzQc39QuhcmApzN23s2RjnMfABrbZvGPsB74SsYqhCYLFsXSULrLs4rokgGXNY5oUZvVm7ZQgHzBv7PPPRW7kFm
view key: 95974a5f8b90d685527f246605e13968dc73f3bc9a72e6db23128220a6579e08
spend key: 109c54394e977d46c2c6385faf05b4a25024ddb476588529b889f6d71912ab0b
```

The output above indicates the network id and default custodian key for the test net. The custodian key should be kept well for future deposit of the test net.

To boot the test net, just launch the node with each configuration directory.

$ mixin kernel -dir /tmp/mixin-7001 -port 7001
$ mixin kernel -dir /tmp/mixin-7002 -port 7002
$ mixin kernel -dir /tmp/mixin-7003 -port 7003
$ mixin kernel -dir /tmp/mixin-7004 -port 7004
$ mixin kernel -dir /tmp/mixin-7005 -port 7005
$ mixin kernel -dir /tmp/mixin-7006 -port 7006
$ mixin kernel -dir /tmp/mixin-7007 -port 7007
```
$ mixin kernel -dir /tmp/mixin-6861
$ mixin kernel -dir /tmp/mixin-6862
$ mixin kernel -dir /tmp/mixin-6863
$ mixin kernel -dir /tmp/mixin-6864
$ mixin kernel -dir /tmp/mixin-6865
$ mixin kernel -dir /tmp/mixin-6866
$ mixin kernel -dir /tmp/mixin-6867
```

Then we can generate a test address and deposit some money into the address.

```
$ mixin createaddress
=>
address: XINBpBaDKtcu5SBuuqE1pwMrdeFvyCwFChdjLS23ewKdoLbURL4iJYCXLvsXP1nVbB3CGRbWg6UgVH8AWVgjSgmenMsrgpRY
view key: be25d97ba8eb80336998facfb033f71713f9c1cabdc417478f831c749fcd9001
spend key: 5189b286e5717ea36435a29dfb1aaddebad5e216b05e8b4de59693dfb9fe1f06
$ mixin signcustodiandeposit -receiver XINBpBaDKtcu5SBuuqE1pwMrdeFvyCwFChdjLS23ewKdoLbURL4iJYCXLvsXP1nVbB3CGRbWg6UgVH8AWVgjSgmenMsrgpRY -custodian 95974a5f8b90d685527f246605e13968dc73f3bc9a72e6db23128220a6579e08109c54394e977d46c2c6385faf05b4a25024ddb476588529b889f6d71912ab0b -asset a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc -chain 8dd50817c082cdcdd6f167514928767a4b52426997bd6d4930eca101c5ff8a27 -asset_key 0xa974c709cfb4566686553a20790685a47aceaa33 -transaction 0x13f805f2593c59becd0b89673390249415f833fc9c821288f69cce5e7c6eb09f -index 0 -amount 100.123
=>
77770005a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc000100000000000000000000000000000000000000000000000000000000000000000000000077778dd50817c082cdcdd6f167514928767a4b52426997bd6d4930eca101c5ff8a27002a3078613937346337303963666234353636363836353533613230373930363835613437616365616133330042307831336638303566323539336335396265636430623839363733333930323439343135663833336663396338323132383866363963636535653763366562303966000000000000000000050254c792e000000001000000050254c792e00001d4ec8c88d30f2f248d302cecbda039ba2a1bfa3f3d02b5f1857c35ff4f7fd98e30a08ef032692ce9551cd7104f742212f9238c888f3418674daf51d53cbca8860003fffe0100000000000000000001000100003ce842d817b3e65cbac0adc8a87bd8102340fda4f4f1f6fdc471c8acd920071be6c360e463863f5082198f225b823f0d33932bec5b6220c3c6cfb57f8cd1830c
$ mixin -n 127.0.0.1:6861 sendrawtransaction -raw 77770005a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc000100000000000000000000000000000000000000000000000000000000000000000000000077778dd50817c082cdcdd6f167514928767a4b52426997bd6d4930eca101c5ff8a27002a3078613937346337303963666234353636363836353533613230373930363835613437616365616133330042307831336638303566323539336335396265636430623839363733333930323439343135663833336663396338323132383866363963636535653763366562303966000000000000000000050254c792e000000001000000050254c792e00001d4ec8c88d30f2f248d302cecbda039ba2a1bfa3f3d02b5f1857c35ff4f7fd98e30a08ef032692ce9551cd7104f742212f9238c888f3418674daf51d53cbca8860003fffe0100000000000000000001000100003ce842d817b3e65cbac0adc8a87bd8102340fda4f4f1f6fdc471c8acd920071be6c360e463863f5082198f225b823f0d33932bec5b6220c3c6cfb57f8cd1830c
=>
{"hash":"bf7f2bdbed2f77c452e91febd48c4a8f876e42895737d2616f9da956fb622888"}
```
36 changes: 25 additions & 11 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,19 +880,26 @@ func setupTestNetCmd(c *cli.Context) error {
return err
}
fmt.Println(string(genesisData))
var gns common.Genesis
err = json.Unmarshal(genesisData, &gns)
if err != nil {
return err
}

peers := make([]string, len(signers))
for i := range signers {
peers[i] = fmt.Sprintf("127.0.0.1:700%d", i+1)
for i, s := range signers {
id := s.Hash().ForNetwork(gns.NetworkId())
peers[i] = fmt.Sprintf("%[email protected]:585%d", id, i+1)
}
peersList := `"` + strings.Join(peers, `","`) + `"`
seedsList := `"` + strings.Join(peers, `","`) + `"`
fmt.Println(peers)
fmt.Printf("network: \t%s\n", gns.NetworkId())
fmt.Printf("custodian:\t%s\n", custodian.String())
fmt.Printf("view key:\t%s\n", custodian.PrivateViewKey.String())
fmt.Printf("spend key:\t%s\n", custodian.PrivateSpendKey.String())

for i, a := range signers {
dir := fmt.Sprintf("/tmp/mixin-700%d", i+1)
dir := fmt.Sprintf("/tmp/mixin-686%d", i+1)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
Expand All @@ -901,13 +908,20 @@ func setupTestNetCmd(c *cli.Context) error {
var configData = []byte(fmt.Sprintf(`
[node]
signer-key = "%s"
consensus-only = true
memory-cache-size = 128
cache-ttl = 3600
[network]
listener = "%s"
peers = [%s]
`, a.PrivateSpendKey.String(), peers[i], peersList))
kernel-operation-period = 700
memory-cache-size = 64
cache-ttl = 180
[storage]
value-log-gc = true
max-compaction-levels = 7
[p2p]
port = 585%d
relayer = true
seeds = [%s]
[rpc]
port = 686%d
object-server = true
`, a.PrivateSpendKey.String(), i+1, seedsList, i+1))

err = os.WriteFile(dir+"/config.toml", configData, 0644)
if err != nil {
Expand Down

0 comments on commit 4cacd2d

Please sign in to comment.