Skip to content

Instantly share code, notes, and snippets.

View sneljo1's full-sized avatar

Jonas Snellinckx sneljo1

View GitHub Profile

Keybase proof

I hereby claim:

  • I am sneljo1 on github.
  • I am sneljo (https://keybase.io/sneljo) on keybase.
  • I have a public key ASAoE6sW9ayQIp-txbkdEko3RXwClmFTMpZmMkZymEpDIwo

To claim this, I am signing this object:

@sneljo1
sneljo1 / react.d.ts
Created November 2, 2018 10:15
Extend react types to support React.memo
import { StatelessComponent, SFCElement } from "react";
declare module "react" {
function memo<P>(
type: StatelessComponent<P>,
compare?: (oldProps: P, newProps: P) => boolean
): SFC<P>;
}
@sneljo1
sneljo1 / script.ts
Created October 7, 2018 10:41
Script for parcel & electron to run both main and renderer process with one cmd
const Bundler = require('parcel-bundler');
const Path = require('path');
const app = require('express')();
const { run } = require('./run-bin');
// Entrypoint file location
const rendererFile = Path.resolve(__dirname, '../static/index.html');
const mainFile = Path.resolve(__dirname, '../src/main/index.ts');
const out = Path.resolve(__dirname, '../dist');
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 stub = new ChaincodeMockStub("MyMockStub", chaincode);
const car0 = {
'make': 'Toyota',
'model': 'Prius',
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`]);
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 query car", async () => {
const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
const response = await mockStub.mockInvoke("tx2", ['queryCar', `CAR0`]);
expect(Transform.bufferToObject(response.payload)).to.deep.eq({
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 init without issues", async () => {
const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
const response = await mockStub.mockInit("tx1", []);
expect(response.status).to.eql(200)
});
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 init without issues", async () => {
const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
// Your test code
});
});
import { ChaincodeMockStub, Transform } from "@theledger/fabric-mock-stub";
const mockStub = new ChaincodeMockStub("MyMockStub", chaincode);
import { MyChaincode } from '../<path_to_your_chaincode_class>';
// You always need your chaincode so it knows which chaincode to invoke on
const chaincode = new MyChaincode();