我尝试对我的松露react-auth项目和Authentification.sol合同进行单元测试,但是当我注册一个新用户并登录他时,我具有相同的typeof var(字符串),相同的字符串,但测试不匹配。 顺便说一句,我尝试发现测试与松露
实际字符串的长度为32,预期只有8,我真的不知道为什么。 方法的合同给我一个字节32。
也感谢您的帮助
测试img的链接: https://i.stack.imgur.com/0P9cx.jpg || https://prnt.sc/mia1yu
var Authentication = artifacts.require("./Authentication.sol");
contract('Authentication', function(accounts) {
let authenticationInstance;
it("Should sign up and log in", function() {
return Authentication.deployed().then((instance) => {
authenticationInstance = instance;
return authenticationInstance.signup(web3.utils.fromAscii('testuser'));
}).then( (result) => {
assert.equal(result.receipt.status, true, "Transaction is done & success")
return authenticationInstance.login()
}).then( (name) => {
let nameConverted = web3.utils.toAscii(name).toString().trim()
assert.equal(nameConverted, 'testuser', "User has the good name")
})
});
});