Skip to content

Instantly share code, notes, and snippets.

@sneljo1
Created March 9, 2018 20:25
Show Gist options
  • Save sneljo1/884e0a4839d1fbbd91371bcf0f3374f4 to your computer and use it in GitHub Desktop.
Save sneljo1/884e0a4839d1fbbd91371bcf0f3374f4 to your computer and use it in GitHub Desktop.
import { MyChaincode } from '../<path_to_your_chaincode_class>';
import { ChaincodeMockStub, Transform } from "@theledger/fabric-mock-stub";
// You always need your chaincode so it knows which chaincode to invoke on
const chaincode = new MyChaincode();
describe('Test MyChaincode', () => {
it("Should be able to add car", async () => {
const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
const response = await mockStub.mockInvoke("tx1", ['createCar', `CAR0`, `prop1`, `prop2`, `prop3`, `owner`]);
expect(response.status).to.eql(200)
const response = await mockStub.mockInvoke("tx1", ['queryCar', `CAR0`]);
expect(Transform.bufferToObject(response.payload)).to.deep.eq({
'make': 'prop1',
'model': 'prop2',
'color': 'prop3',
'owner': 'owner',
'docType': 'car'
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment