2018-04-08 18:40

CyberMiles测试链Travis测试指南

3月30日,CyberMiles测试链Travis正式上线。具体而言,Travis测试链有以下的技术特点为:

1.性能更高,交易速度是以太坊的100倍,同时可完全兼容以太坊;
2.安全性更高,可以主动阻止一些常见的智能合约漏洞,这些漏洞会导致以太坊资金丢失;
3.费用更低,在不牺牲网络安全的情况下,能够免除大多数常见操作的交易费。
Travis现正式开放测试,欢迎各位开发人员按照下面的指南进行测试。 

WechatIMG360

访问Travis 测试链:

Travis 测试链与以太坊完全兼容——但速度比以太坊快100倍,而且针对电子商务应用程序进行了协议级的优化。

首先,您需要使用以太坊客户端。例如,您可以使用GETH连接到我们测试链的节点。

geth attach rpc:http://travis-node0.cybermiles.io:8545

在这里,您可以使用web3命令来创建新账户,在账户之间进行交易、创建、上传以及执行智能合约。

 

Welcome to the Geth JavaScript console!

> personal.newAccount()

...

 

您还可以使用Truffle等工具在Travis 测试链上构建和测试智能合约。您只需使用travis-node0.cybermiles.io节点,就把它当作一个常规的以太坊节点即可。

获得一些测试的CMT

现在您已经在Travis 测试链上创建了两个帐户:0x1234FROM0x1234DEST。现在是时候获得一些测试的CMT了。请访问网站http://travis-faucet.cybermiles.io,并向帐户0x1234FROM索要100个测试的 CMT。 TEST智能合约会发出的100个测试代币给账户。

您可以在您的两个帐户之间测试交易。

> personal.unlockAccount("0x1234FROM","password")

true

...

 
> eth.sendTransaction({from:"0x1234FROM", to:"0x1234DEST",value:1000})

...

 
>eth.getBalance("0x1234DEST")

...

 

您还可以这样用测试代币来测试智能合约交易:

>abi=[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"INITIAL_SUPPLY","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]

> tokenContract = web3.eth.contract(abi)

>tokenInstance=

tokenContract.at("0xb6b29ef90120bec597939e0eda6b8a9164f75deb")

>tokenInstance.transfer.sendTransaction("0x1234DEST",1000,{from:"0x1234FROM"})

 

在10秒后,您可以按如下的方式来查看收款账户的余额:

> tokenInstance.balanceOf.call("0x1234DEST") 
交易免费:

在CyberMiles区块链中,我们已经使大多数的交易免费,除了有大量交易的用户或发送垃圾邮件者。您可以在GETH控制台中尝试一下。

>eth.sendTransaction({from:"0x1234FROM",

to:"0x1234DEST",value:1000,gasPrice:0})

...

要尝试基于智能合约的免交易费的代币交易,可以在GETH控制台中使用以下内容。
>tokenInstance.transfer.sendTransaction("0x1234DEST", 1000, {from: "0x1234FROM", gasPrice: 0})
压力测试:

我们使用我们的基准测试工具对区块链的性能进行压力测试。该工具是一个Node. js JavaScript应用程序。首先这个工具会加载一批交易,然后发送到Travis上,并等待所有的交易都被记录在区块链上,最后计算每秒交易速度(TPS)。

以下是前提条件:

1. 安装node.js(8.0及以上版本)。

2. 下载http://travis-faucet.cybermiles.io/enduser.zip,并解压到一个终端用户(enduser)的文件夹中。

3. 更改到该文件夹:cd终端用户(cd enduser)。

4. 编辑config / default.json文件:将from,to和paassword更改到刚刚创建的帐户中。

5. 现在,请确保您在数据中心环境下运行以下脚本。例如,在美国数据中心内充分配置的AWS 虚拟机内运行。如果您用笔记本电脑运行,将无法从单个网络节点完全融入Travis 测试链。

sendTx.js脚本向Travis 测试链发送一批CMT交易。

node sendTx.js
sendTokenTx.js脚本向Travis 测试链发送一批TEST智能合约交易。
node sendTokenTx.js
 您可以将您的结果发送至travis@cybermiles.io,让我们了解您的配置,数据中心环境以及您达到的每秒CMT / TEST交易数。

web3-cmt.js客户端库:

您可能已经注意到,在sendTx.jssendTokenTx.js脚本中,我们已经使用web3-cmt.js库来访问cmt模块,以取代以太坊web3.js库中的eth模块。

web3-cmt.js客户端库支持CyberMiles区块链的特定功能,包括质押和治理。并且它的cmt模块也完全兼容web3的eth模块。

关于“如何防止地址错误” 的内容,将在近期更新,敬请期待。

本文链接:https://www.8btc.com/article/189906
转载请注明文章出处

评论(1)
登录 账号发表你的看法,还没有账号?立即免费 注册
去吧皮卡喵 2018-04-08
有性能,有环保,有安全。是不是完全去中心化?
下载
分享
收藏
阅读
评论
1
点赞
上一篇
下一篇