I am looking at the log result of the variable "result".
By running a few test, i am pretty sure inside the id and the price has value.
However the console logs only show [BN] instead of <BN:1>.
How can it print out the value in console logs?
Smart Contract fucntion:
function createProduct(string memory _name, uint _price) public {
productCount ++;
products[productCount] = Product(productCount, _name, _price, msg.sender, false);
emit ProductCreated(productCount, _name, _price, msg.sender, false);
}
Test code:
describe('products', async() => {
let productCount, result
before (async () => {
result = await marketplace.createProduct('iphone x', web3.utils.toWei('1','Ether'));
productCount = await marketplace.productCount();
} )
it('creates products', async () => {
// SUCESS
assert.equal(productCount, 1);
console.log(result.logs);
})
})
Result:
args: Result {
'0': [BN],
'1': 'iphone x',
'2': [BN],
'3': '0xa1e26adB8eF905FdE80bBf9ed88D6784618a5B1b',
'4': false,
__length__: 5,
id: [BN],
name: 'iphone x',
price: [BN],
owner: '0xa1e26adB8eF905FdE80bBf9ed88D6784618a5B1b',
purchased: false
Expected result:
args: Result {
'0': <BN:1>,
'1': 'iphone x',
'2': <BN:de0b6b3a7640000>,
'3': '0xa1e26adB8eF905FdE80bBf9ed88D6784618a5B1b',
'4': false,
__length__: 5,
id: <BN:1>,
name: 'iphone x',
price: <BN:de0b6b3a7640000>,
owner: '0xa1e26adB8eF905FdE80bBf9ed88D6784618a5B1b',
purchased: false
question from:
https://stackoverflow.com/questions/65923995/console-log-bn-did-not-show-the-value