Tengo una fábrica de contratos y un subcontrato, y ahora quiero probar el subcontrato recién creado. Este debería ser bastante simple, espero.
it("test CoinNewCoin - Test Created Coin ", function (){
var fromOwner = accounts[0];
var coinFactory;
var coinNewCoin;
return CoinFactory.deployed().then((instance) => {
coinFactory = instance;
}).then(() => {
return coinFactory.getCoinAddress(fromOwner, {from: fromOwner});
}).then((result) => {
console.log(result);
return CoinNewCoin.at(result).then((instance) => {
}).then((instance) => {
console.log(instance); // this is the undefined.
coinNewCoin = instance;
return coinNewCoin.getAuthorizationKey();
})
}).then((result) => {
console.log(result);
});
});
editar: secuencias de comandos actualizadas.
devuelve CoinNewCoin.at(resultado).getAuthorizationKey();
La arroba (dirección), era la clave. gracias -buenas vibraciones!
it("test CoinNewCoin - Test Created Coin ", function (){
var fromOwner = accounts[0];
var coinFactory;
var coinNewCoin;
var coinAddress;
return CoinFactory.deployed().then((instance) => {
coinFactory = instance;
}).then(() => {
return coinFactory.getCoinAddress(fromOwner, {from: fromOwner});
}).then((result) => {
return CoinNewCoin.at(result).getAuthorizationKey();
}).then((result) => {
var testVal = result.toString().split(",");
assert.equal("00000000000000000000000000000000",web3.toAscii(testVal[0]), "Coin contract is was not created, fail!")
});
});
buena vibración
coinFactory.address
en web3 v0.x ycoinFactory._address
en web3 v1.x.sombra
buena vibración
NewCoin.deployed()
aNewCoin.at(result)
.sombra