Skip to content

Instantly share code, notes, and snippets.

@zhaojun-sh
Last active May 21, 2020 10:07
Show Gist options
  • Save zhaojun-sh/f7d23bb9ae14b6275053aabafec0a787 to your computer and use it in GitHub Desktop.
Save zhaojun-sh/f7d23bb9ae14b6275053aabafec0a787 to your computer and use it in GitHub Desktop.

dcrm-client测试程序

运行dcrm测试网络

编译dev分支的最新代码.

git clone https://github.com/fsn-dev/dcrm-walletService.git
cd dcrm-walletService
git checkout dev 
make

1.运行bootnode

./bin/cmd/bootnode -genkey bootnode.key

./bin/cmd/bootnode -nodekey ./bin/cmd/bootnode.key

2.运行3个dcrm节点

./gdcrm --genkey node1.key
./gdcrm --genkey node2.key
./gdcrm --genkey node3.key

./gdcrm --nodekey node1.key --rpcport 9011 --port 8011 --datadir ./node1 --bootnodes enode://7aeaca86c21017581af71f0631ce7f62f24e58ad301d0a42f4926354720c30519003e575628089ba2be5108e7f17b8b3153a5ab5c850da3b5e7022d79ec94037@127.0.0.1:4440

./gdcrm --nodekey node2.key --rpcport 9012 --port 8012 --datadir ./node2 --bootnodes enode://7aeaca86c21017581af71f0631ce7f62f24e58ad301d0a42f4926354720c30519003e575628089ba2be5108e7f17b8b3153a5ab5c850da3b5e7022d79ec94037@127.0.0.1:4440

./gdcrm --nodekey node3.key --rpcport 9013 --port 8013 --datadir ./node3 --bootnodes enode://7aeaca86c21017581af71f0631ce7f62f24e58ad301d0a42f4926354720c30519003e575628089ba2be5108e7f17b8b3153a5ab5c850da3b5e7022d79ec94037@127.0.0.1:4440

建2/3组获取gid

./dcrm-client -test SetGroup -url http://127.0.0.1:9011 -ts 2/3 -node http://127.0.0.1:9011 -node http://127.0.0.1:9012 -node http://127.0.0.1:9013

申请个人账户

./dcrm-client -test REQDCRMADDR -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 1 -url http://127.0.0.1:9011

创建共管账户

1. 建2/3组获取gid

 ./dcrm-client -test SetGroup -url http://127.0.0.1:9011 -ts 2/3 -node http://127.0.0.1:9011 -node http://127.0.0.1:9012 -node http://127.0.0.1:9013

2. 获取3节点签名enode

 ./dcrm-client -test EnodeSig -url http://127.0.0.1:9013 -keystore ~/Downloads/UTC--2020-04-23T15-19-31.919Z--4bb81aeee94b383211ece6e840ff6173e74b25b5 -passwd 123456789

3. 获取2节点签名enode

 ./dcrm-client -test EnodeSig -url http://127.0.0.1:9012 -keystore ~/Downloads/UTC--2020-04-23T15-20-09.393Z--f3dc381f4e30e180c0e2fee5405e5424d41d134f -passwd 123456789

4. 获取1节点签名enode

./dcrm-client -test EnodeSig -url http://127.0.0.1:9011

5. 用节点1发起,用户申请创建共管账号 -sig参数是各节点签名的enode

./dcrm-client -test REQDCRMADDR -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 0 -url http://127.0.0.1:9011 -sig enode://c015c5d26c76fed1f966e258c576d951774364745b11aba43ac8d1853b47202bde2ec6cbb86072b39497a43f622a779e3a355143db2904a209b955893422824a@127.0.0.1:80110x785a76241ac536ed7282e92d9333a31498aae6ce6f8e51bff9e378efc19a9b7829d5f3ea0895189b682f2eabcf7f0f155ca7a629ad242ea4e198f58491283b5201 -sig enode://6ce5fb11959a34a8f1d66bbf738303951c0774ee35210de1f99f2f5e11ef8aa87704274682c4d4fcb652d111649c7450160f924f25346276f23706653a686088@127.0.0.1:80120xce5d8d248a54bc1960c9365c8336786ac9822e53660193aebac4c06d93d03db02c05db3786ed5599603e024c63ee4024fd91c1ece7d41fdc886ea4aaa9c1c32e00 -sig enode://7564acc03e4464e5e8d75217c235e01291d340b01ddf16881fb9b609cfe421829590ebb6ba6b1555679012d9bd28b1be0c3aa96dac3a7ec3ed6ae391b30a16b6@127.0.0.1:80130x4307924e97063a8f07fd1e8f89d802227bb826da5fe2c3b2955bcaacf7bd327437105c1cfe82f8fa1ec9067cf2825850337e655c7fc0165a5d0d53ab4d7443f101

6.审批创建共管账户

在节点2和3上用上面命令获取的keyid作为-key参数,发送同意审批。发起节点1不需要审批同意。

./dcrm-client -test ACCEPTREQADDR  -url http://127.0.0.1:9012 -keystore ~/Downloads/UTC--2020-04-23T15-20-09.393Z--f3dc381f4e30e180c0e2fee5405e5424d41d134f -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

./dcrm-client -test ACCEPTREQADDR  -url http://127.0.0.1:9013 -keystore ~/Downloads/UTC--2020-04-23T15-19-31.919Z--4bb81aeee94b383211ece6e840ff6173e74b25b5 -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

7. 查询共管账户创建结果,获取pubkey

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccounts","params":["0x00c37841378920E2BA5151a5d1E074Cf367586c4","0"],"id":67}' http://127.0.0.1:9011

个人账户lockout测试

1. 先生成个人模式账户,获取pubKey和user account;

./dcrm-client -test REQDCRMADDR -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 1 -url http://127.0.0.1:9011

2. 拿到pubKey后调用curl dcrm_getAccountsBalance获取dcrm的FSN地址,充值FSN测试币;

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccountsBalance","params":["04f6380894cb47734d27dcb3c3de31c12d30e862f51ecb189fd21c02f4b4b1e66cd5f23cef25fb3d8082c376cc43f7a0093b4eb149b160af8d206998b6ef4af8c0","0x00c37841378920E2BA5151a5d1E074Cf367586c4"],"id":67}' http://127.0.0.1:9011

3. 拿到dcrm FSN地址作为lockout测试的-from参数 运行dcrm-client命令测试lockout

./dcrm-client -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -url http://127.0.0.1:9012 --ts 2/3 -test LOCKOUT -mode 1 -from 0x2d559B4cB9Ab109e95d6B59b645c3A48fE6e4e61 

共管账户同意审批lockout测试

1.参考之前步骤创建并审批共管账户

2.拿到DCRM账户pubKey后调用curl dcrm_getAccountsBalance获取dcrm的FSN地址,充值FSN测试币

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccountsBalance","params":["04f6380894cb47734d27dcb3c3de31c12d30e862f51ecb189fd21c02f4b4b1e66cd5f23cef25fb3d8082c376cc43f7a0093b4eb149b160af8d206998b6ef4af8c0","0x00c37841378920E2BA5151a5d1E074Cf367586c4"],"id":67}' http://127.0.0.1:9011

3.拿到dcrm FSN地址作为lockout测试的-from参数 运行dcrm-client命令测试lockout,注意-mode=0

./dcrm-client -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -url http://127.0.0.1:9011 --ts 2/3 -test LOCKOUT -mode 0 -from 0x2d559B4cB9Ab109e95d6B59b645c3A48fE6e4e61 

4.发起者发送lockout请求后,其他节点发送审批同意

./dcrm-client -test ACCEPTLOCKOUT  -url http://127.0.0.1:9012 -keystore ~/Downloads/UTC--2020-04-23T15-20-09.393Z--f3dc381f4e30e180c0e2fee5405e5424d41d134f -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

./dcrm-client -test ACCEPTLOCKOUT  -url http://127.0.0.1:9013 -keystore ~/Downloads/UTC--2020-04-23T15-19-31.919Z--4bb81aeee94b383211ece6e840ff6173e74b25b5 -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

5.重新用dcrm_getAccountsBalance获取dcrm的FSN地址余额判断有没有成功发送lockout

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccountsBalance","params":["04f6380894cb47734d27dcb3c3de31c12d30e862f51ecb189fd21c02f4b4b1e66cd5f23cef25fb3d8082c376cc43f7a0093b4eb149b160af8d206998b6ef4af8c0","0x00c37841378920E2BA5151a5d1E074Cf367586c4"],"id":67}' http://127.0.0.1:9011

个人账户sign测试

1. 先生成个人模式账户,获取pubKey;

./dcrm-client -test REQDCRMADDR -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 1 -url http://127.0.0.1:9011

2. 测试sign接口

./dcrm-client -test SIGN -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 1 -url http://127.0.0.1:9011 -pubkey 04fa589c020026e11005383b59a6f8a0348380741c893d04a7fc7beb069ce030f6907c68fa6fd0e3aca43265b7aee86db8dc2f4af08a5fb9cee963e10445e7b72d

共管账户同意审批sign测试

1. 首先创建共管账户审批通过后,curl获得账户pubkey

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccounts","params":["0x00c37841378920E2BA5151a5d1E074Cf367586c4","0"],"id":67}' http://127.0.0.1:9011

2. 测试共管的sign接口

./dcrm-client -test SIGN -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -mode 0 -url http://127.0.0.1:9011 -pubkey 04fa589c020026e11005383b59a6f8a0348380741c893d04a7fc7beb069ce030f6907c68fa6fd0e3aca43265b7aee86db8dc2f4af08a5fb9cee963e10445e7b72d

3. 其他节点审批同意sign请求

./dcrm-client -test ACCEPTSIGN  -url http://127.0.0.1:9012 -keystore ~/Downloads/UTC--2020-04-23T15-20-09.393Z--f3dc381f4e30e180c0e2fee5405e5424d41d134f -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

./dcrm-client -test ACCEPTSIGN  -url http://127.0.0.1:9013 -keystore ~/Downloads/UTC--2020-04-23T15-19-31.919Z--4bb81aeee94b383211ece6e840ff6173e74b25b5 -passwd 123456789 -key 0x0336f740d84844f08fc61d700cc3183d0a96eade10061145a2563bc04a924d7d

4. 根据key查询sign结果的Rsv字段

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getSignStatus","params":["0xeca87b94f8dd53b51c33e0981d4b7a457b1e3281d9ce5a36189ff8e1de9e809b"],"id":67}' http://127.0.0.1:9011

dcrm账户reshare测试

1. 首先创建门限共管账户审批通过后,curl获得账户pubkey

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_getAccounts","params":["0x00c37841378920E2BA5151a5d1E074Cf367586c4","0"],"id":67}' http://127.0.0.1:9011

2. 假设节点3密钥分片丢失,删除node3节点目录下的内容,然后创建1和2节点的门限子组

./dcrm-client -test SetGroup -url http://127.0.0.1:9011 -ts 2/2 -node http://127.0.0.1:9011 -node http://127.0.0.1:9012

3. 测试reshare接口,使用node1.key中私钥作为-pkey参数进行reshare签名申请

./dcrm-client -test RESHARE  -url http://127.0.0.1:9011 -ts 2/3 -gid 50ade4633ff5051a4805da762725d1e1c41d4e936f0299c2eea5199e2b46812fb1d4aac038ae389ec957852a50a8baeade1c9f721ebe68f8565049b3c96c1700 -tsgid 1e75bd2f9608991789e5dbbacdc4a75f252bda337b2039326d04e7193b0449fd36a5b339e391948ecb869fd60aab86eb52d614089c4ccd5a0a81a914bdb85ced -pkey 9f61408b96263e4978376c93bc4b78b7c63c5667da372d409cf762c0b34487af -pubkey 045027420ff062dd9e16d0ac4c10834c8cd738c0e4eb03224d695a6914cd717f472a495a57eb77f1c7b1fe4259b9983daa579f28be557c164e3a331c5b2e499536

4. 节点审批reshare,使用节点的node*.key的私钥作为-pkey参数进行reshare审批确认

./dcrm-client -test ACCEPTRESHARE  -url http://127.0.0.1:9012 -pkey xxxxxxx 
./dcrm-client -test ACCEPTRESHARE  -url http://127.0.0.1:9013 -pkey xxxxxxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment