step 7: test create post

This commit is contained in:
Pascal Precht 2019-01-29 12:12:24 +01:00
parent 5ce277e379
commit bf3838677c
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 16 additions and 0 deletions

View File

@ -1,7 +1,23 @@
const DReddit = embark.require('Embark/contracts/DReddit');
const ipfsHash = 'Qmc5gCcjYypU7y28oCALwfSvxCBskLuPKWpK4qpterKC7z';
config({
contracts: {
DReddit: {}
}
})
contract('DReddit', () => {
it('should work', () => {
assert.ok(true);
});
it('should be able to create a post and receive it via contract event', async () => {
let receipt = await DReddit.methods.createPost(web3.utils.fromAscii(ipfsHash)).send();
const event = receipt.events.NewPost;
postId = event.returnValues.postId;
assert.equal(web3.utils.toAscii(event.returnValues.description), ipfsHash);
});
});