From bf3838677c1c0f135844c1aed1d5d4d524196f42 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Tue, 29 Jan 2019 12:12:24 +0100 Subject: [PATCH] step 7: test create post --- test/DReddit_spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/DReddit_spec.js b/test/DReddit_spec.js index 9f53588..a03db19 100644 --- a/test/DReddit_spec.js +++ b/test/DReddit_spec.js @@ -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); + }); });