How to use the fabric-shim.ChaincodeStub.RESPONSE_CODE function in fabric-shim

To help you get started, we’ve selected a few fabric-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-chaincode-node / test / typescript / chaincode.ts View on Github external
if (fcn === 'SuccessShim') {
            return Shim.success();
        }

        await this.testAll(stub);

        if (fcn === 'nopayload') {
            return shim.success();
        }

        if (fcn === 'myReturnCode') {
            let rc: number;
            rc = ChaincodeStub.RESPONSE_CODE.OK;
            rc = shim.RESPONSE_CODE.OK;
            rc = ChaincodeStub.RESPONSE_CODE.ERRORTHRESHOLD;
            rc = shim.RESPONSE_CODE.ERRORTHRESHOLD;
            rc = ChaincodeStub.RESPONSE_CODE.ERROR;
            rc = shim.RESPONSE_CODE.ERROR;
            rc++;
        }

        return shim.success(Buffer.from('all good'));
    }
github hyperledger / fabric-chaincode-node / test / typescript / chaincode.ts View on Github external
return Shim.error(Buffer.from(err.message));
        }

        if (fcn === 'SuccessShim') {
            return Shim.success();
        }

        await this.testAll(stub);

        if (fcn === 'nopayload') {
            return shim.success();
        }

        if (fcn === 'myReturnCode') {
            let rc: number;
            rc = ChaincodeStub.RESPONSE_CODE.OK;
            rc = shim.RESPONSE_CODE.OK;
            rc = ChaincodeStub.RESPONSE_CODE.ERRORTHRESHOLD;
            rc = shim.RESPONSE_CODE.ERRORTHRESHOLD;
            rc = ChaincodeStub.RESPONSE_CODE.ERROR;
            rc = shim.RESPONSE_CODE.ERROR;
            rc++;
        }

        return shim.success(Buffer.from('all good'));
    }
github IBM-Blockchain / generator-fabric / generators / chaincode / templates / typescript / src / chaincode.spec.ts View on Github external
it('should work', async () => {
            const cc = new Chaincode();
            const stub = sinon.createStubInstance(ChaincodeStub);
            stub.getFunctionAndParameters.returns({ fcn: 'initFunc', params: [] });
            let res = await cc.Init(stub);
            res.status.should.equal(ChaincodeStub.RESPONSE_CODE.OK);
            stub.getFunctionAndParameters.returns({ fcn: 'invokeFunc', params: [] });
            res = await cc.Invoke(stub);
            res.status.should.equal(ChaincodeStub.RESPONSE_CODE.OK);
        });
github IBM-Blockchain / generator-fabric / generators / chaincode / templates / typescript / src / chaincode.spec.ts View on Github external
it('should work', async () => {
            const cc = new Chaincode();
            const stub = sinon.createStubInstance(ChaincodeStub);
            stub.getFunctionAndParameters.returns({ fcn: 'initFunc', params: [] });
            const res = await cc.Init(stub);
            res.status.should.equal(ChaincodeStub.RESPONSE_CODE.OK);
        });