public void TestPutPrivateData() { ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null); byte[] value = new byte[] { 0x10, 0x20, 0x30 }; stub.PutPrivateData("testcoll", "key", value); handler.Verify(a => a.PutStateAsync("myc", "txId", "testcoll", "key", ByteString.CopyFrom(value), token)); try { stub.PutPrivateData(null, "key", value); Assert.Fail("Null collection check fails"); } catch (ArgumentException) { //ignored } try { stub.PutPrivateData("", "key", value); Assert.Fail("Empty collection check fails"); } catch (ArgumentException) { //ignored } try { stub.PutPrivateData("testcoll", null, value); Assert.Fail("Null key check fails"); } catch (ArgumentException) { //ignored } try { stub.PutPrivateData("testcoll", "", value); Assert.Fail("Empty key check fails"); } catch (ArgumentException) { //ignored } }
public void TestPutStringPrivateData() { ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null); string value = "TEST"; stub.PutPrivateData("testcoll", "key", value); handler.Verify(a => a.PutStateAsync("myc", "txId", "testcoll", "key", ByteString.CopyFromUtf8(value), token)); }