difftreelog
toggleContractWhiteList tests
in: master
4 files changed
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -26,7 +26,8 @@
"testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
"testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",
"testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",
- "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts"
+ "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
+ "testToggleContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractWhiteList.test.ts"
},
"author": "",
"license": "Apache 2.0",
tests/src/contracts.test.tsdiffbeforeafterboth1import chai from "chai";2import chaiAsPromised from 'chai-as-promised';3import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";4import fs from "fs";5import { Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract } from "@polkadot/api-contract";6import { IKeyringPair } from "@polkadot/types/types";7import { ApiPromise, Keyring } from "@polkadot/api";8import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";9import privateKey from "./substrate/privateKey";1011chai.use(chaiAsPromised);12const expect = chai.expect;13import { BigNumber } from 'bignumber.js';14import { findUnusedAddress } from './util/helpers';1516const value = 0;17const gasLimit = 3000n * 1000000n;18const endowment = `1000000000000000`;19const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';2021function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<Blueprint> {22 return new Promise<Blueprint>(async (resolve, reject) => {23 const unsub = await code24 .createBlueprint()25 .signAndSend(alice, (result) => {26 if (result.status.isInBlock || result.status.isFinalized) {27 // here we have an additional field in the result, containing the blueprint28 resolve(result.blueprint);29 unsub();30 }31 })32 });33}3435function deployContract(alice: IKeyringPair, blueprint: Blueprint) : Promise<any> {36 return new Promise<any>(async (resolve, reject) => {37 const endowment = 1000000000000000n;38 const initValue = true;3940 const unsub = await blueprint.tx41 .new(endowment, gasLimit, initValue)42 .signAndSend(alice, (result) => {43 if (result.status.isInBlock || result.status.isFinalized) {44 unsub();45 resolve(result);46 }47 }); 48 });49}5051async function prepareDeployer(api: ApiPromise) {52 // Find unused address53 const deployer = await findUnusedAddress(api);5455 // Transfer balance to it56 const keyring = new Keyring({ type: 'sr25519' });57 const alice = keyring.addFromUri(`//Alice`);58 let amount = new BigNumber(endowment);59 amount = amount.plus(1e15);60 const tx = api.tx.balances.transfer(deployer.address, amount.toFixed());61 await submitTransactionAsync(alice, tx);6263 return deployer;64}6566export async function deployFlipper(api: ApiPromise): Promise<[Contract, IKeyringPair]> {67 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));68 const abi = new Abi(metadata);6970 const deployer = await prepareDeployer(api);7172 const wasm = fs.readFileSync('./src/flipper/flipper.wasm');7374 const code = new CodePromise(api, abi, wasm);7576 const blueprint = await deployBlueprint(deployer, code);77 const contract = (await deployContract(deployer, blueprint))['contract'] as Contract;7879 const initialGetResponse = await getFlipValue(contract, deployer);80 expect(initialGetResponse).to.be.true;8182 return [contract, deployer];83}8485async function getFlipValue(contract: Contract, deployer: IKeyringPair) {86 const result = await contract.query.get(deployer.address, value, gasLimit);8788 if(!result.result.isSuccess) {89 throw `Failed to get flipper value`;90 }91 return (result.result.asSuccess.data[0] == 0x00) ? false : true;92}9394describe('Contracts', () => {95 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {96 await usingApi(async api => {97 const [contract, deployer] = await deployFlipper(api);98 const initialGetResponse = await getFlipValue(contract, deployer);99100 const bob = privateKey("//Bob");101 const flip = contract.exec('flip', value, gasLimit);102 await submitTransactionAsync(bob, flip);103104 const afterFlipGetResponse = await getFlipValue(contract, deployer);105 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');106 });107 });108109 it(`Whitelisted account can call contract.`, async () => {110 await usingApi(async api => {111 const bob = privateKey("//Bob");112113 const [contract, deployer] = await deployFlipper(api);114115 let expectedFlipValue = await getFlipValue(contract, deployer);116117 const flip = contract.exec('flip', value, gasLimit);118 await submitTransactionAsync(bob, flip);119 expectedFlipValue = !expectedFlipValue;120 const afterFlip = await getFlipValue(contract,deployer);121 expect(afterFlip).to.be.eq(expectedFlipValue, `Anyone can call new contract.`);122123 const deployerCanFlip = async () => {124 expectedFlipValue = !expectedFlipValue;125 const deployerFlip = contract.exec('flip', value, gasLimit);126 await submitTransactionAsync(deployer, deployerFlip);127 const aliceFlip1Response = await getFlipValue(contract, deployer);128 expect(aliceFlip1Response).to.be.eq(expectedFlipValue, `Deployer always can flip.`);129 };130 await deployerCanFlip();131132 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);133 const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);134 const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);135 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;136 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);137 expect(flipValueAfterEnableWhiteList).to.be.eq(expectedFlipValue, `Enabling whitelist doesn't make it possible to call contract for everyone.`);138139 await deployerCanFlip();140141 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);142 const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);143 const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);144 await submitTransactionAsync(bob, flipWithWhitelistedBob);145 expectedFlipValue = !expectedFlipValue;146 const flipAfterWhiteListed = await getFlipValue(contract,deployer);147 expect(flipAfterWhiteListed).to.be.eq(expectedFlipValue, `Bob was whitelisted, now he can flip.`);148149 await deployerCanFlip();150151 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);152 const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);153 const bobRemoved = contract.exec('flip', value, gasLimit);154 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;155 const afterBobRemoved = await getFlipValue(contract, deployer);156 expect(afterBobRemoved).to.be.eq(expectedFlipValue, `Bob can't call contract, now when he is removeed from white list.`);157158 await deployerCanFlip();159160 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);161 const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);162 const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);163 await submitTransactionAsync(bob, whiteListDisabledFlip);164 expectedFlipValue = !expectedFlipValue;165 const afterWhiteListDisabled = await getFlipValue(contract,deployer);166 expect(afterWhiteListDisabled).to.be.eq(expectedFlipValue, `Anyone can call contract with disabled whitelist.`);167168 });169 });170171 it('Can initialize contract instance', async () => {172 await usingApi(async (api) => {173 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));174 const abi = new Abi(metadata);175 const newContractInstance = new Contract(api, abi, marketContractAddress);176 expect(newContractInstance).to.have.property('address');177 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);178 });179 });180181 it.skip('Can transfer balance using smart contract.', async () => {182 await usingApi(async api => {183 // const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);184 // const wasm = fs.readFileSync('./src/balance-transfer-contract/calls.wasm');185 // const contract = compactAddLength(u8aToU8a(wasm));186187 // const metadata = JSON.parse(fs.readFileSync('./src/balance-transfer-contract/metadata.json').toString('utf-8'));188 // const abi = new Abi(api.registry as any, metadata);189190 // const alicesPrivateKey = privateKey('//Alice');191192 // const contractHash = await deployContract(api, contract, alicesPrivateKey);193194 // // const args = abi.constructors[0]();195 // const instanceAccountId = await instantiateContract(api, contractHash, /*args,*/ alicesPrivateKey);196 // const contractInstance = new ContractPromise(api, abi, instanceAccountId);197 // const bob = new GenericAccountId(api.registry, bobsPublicKey);198199 // const transfer = contractInstance.exec('balance_transfer', 0, 1000000000000n, [bob, new u128(api.registry, 1000000)]);200 // await submitTransactionAsync(alicesPrivateKey, transfer);201202 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);203204 // expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;205 // expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;206 });207 });208});1import chai from "chai";2import chaiAsPromised from 'chai-as-promised';3import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";4import fs from "fs";5import { Abi, ContractPromise as Contract } from "@polkadot/api-contract";6import privateKey from "./substrate/privateKey";7import {8 deployFlipper,9 getFlipValue10} from "./util/contracthelpers";1112chai.use(chaiAsPromised);13const expect = chai.expect;1415const value = 0;16const gasLimit = 3000n * 1000000n;17const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';1819describe('Contracts', () => {20 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {21 await usingApi(async api => {22 const [contract, deployer] = await deployFlipper(api);23 const initialGetResponse = await getFlipValue(contract, deployer);2425 const bob = privateKey("//Bob");26 const flip = contract.exec('flip', value, gasLimit);27 await submitTransactionAsync(bob, flip);2829 const afterFlipGetResponse = await getFlipValue(contract, deployer);30 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');31 });32 });3334 it('Can initialize contract instance', async () => {35 await usingApi(async (api) => {36 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));37 const abi = new Abi(metadata);38 const newContractInstance = new Contract(api, abi, marketContractAddress);39 expect(newContractInstance).to.have.property('address');40 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);41 });42 });4344 it.skip('Can transfer balance using smart contract.', async () => {45 await usingApi(async api => {46 // const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);47 // const wasm = fs.readFileSync('./src/balance-transfer-contract/calls.wasm');48 // const contract = compactAddLength(u8aToU8a(wasm));4950 // const metadata = JSON.parse(fs.readFileSync('./src/balance-transfer-contract/metadata.json').toString('utf-8'));51 // const abi = new Abi(api.registry as any, metadata);5253 // const alicesPrivateKey = privateKey('//Alice');5455 // const contractHash = await deployContract(api, contract, alicesPrivateKey);5657 // // const args = abi.constructors[0]();58 // const instanceAccountId = await instantiateContract(api, contractHash, /*args,*/ alicesPrivateKey);59 // const contractInstance = new ContractPromise(api, abi, instanceAccountId);60 // const bob = new GenericAccountId(api.registry, bobsPublicKey);6162 // const transfer = contractInstance.exec('balance_transfer', 0, 1000000000000n, [bob, new u128(api.registry, 1000000)]);63 // await submitTransactionAsync(alicesPrivateKey, transfer);6465 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);6667 // expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;68 // expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;69 });70 });71});tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -0,0 +1,151 @@
+import chai from "chai";
+import chaiAsPromised from 'chai-as-promised';
+import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
+import privateKey from "./substrate/privateKey";
+import {
+ deployFlipper,
+ getFlipValue
+} from "./util/contracthelpers";
+import {
+ getGenericResult
+} from "./util/helpers"
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+const value = 0;
+const gasLimit = 3000n * 1000000n;
+
+describe('Integration Test toggleContractWhiteList', () => {
+
+ it(`Enable white list contract mode`, async () => {
+ await usingApi(async api => {
+ const [contract, deployer] = await deployFlipper(api);
+
+ const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+ const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);
+ const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);
+ const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+
+ expect(getGenericResult(enableEvents).success).to.be.true;
+ expect(enabledBefore).to.be.false;
+ expect(enabled).to.be.true;
+ });
+ });
+
+ it(`Only whitelisted account can call contract`, async () => {
+ await usingApi(async api => {
+ const bob = privateKey("//Bob");
+
+ const [contract, deployer] = await deployFlipper(api);
+
+ let expectedFlipValue = await getFlipValue(contract, deployer);
+
+ const flip = contract.exec('flip', value, gasLimit);
+ await submitTransactionAsync(bob, flip);
+ expectedFlipValue = !expectedFlipValue;
+ const afterFlip = await getFlipValue(contract,deployer);
+ expect(afterFlip).to.be.eq(expectedFlipValue, `Anyone can call new contract.`);
+
+ const deployerCanFlip = async () => {
+ expectedFlipValue = !expectedFlipValue;
+ const deployerFlip = contract.exec('flip', value, gasLimit);
+ await submitTransactionAsync(deployer, deployerFlip);
+ const aliceFlip1Response = await getFlipValue(contract, deployer);
+ expect(aliceFlip1Response).to.be.eq(expectedFlipValue, `Deployer always can flip.`);
+ };
+ await deployerCanFlip();
+
+ const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);
+ const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);
+ const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);
+ await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;
+ const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);
+ expect(flipValueAfterEnableWhiteList).to.be.eq(expectedFlipValue, `Enabling whitelist doesn't make it possible to call contract for everyone.`);
+
+ await deployerCanFlip();
+
+ const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);
+ const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);
+ const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);
+ await submitTransactionAsync(bob, flipWithWhitelistedBob);
+ expectedFlipValue = !expectedFlipValue;
+ const flipAfterWhiteListed = await getFlipValue(contract,deployer);
+ expect(flipAfterWhiteListed).to.be.eq(expectedFlipValue, `Bob was whitelisted, now he can flip.`);
+
+ await deployerCanFlip();
+
+ const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);
+ const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);
+ const bobRemoved = contract.exec('flip', value, gasLimit);
+ await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;
+ const afterBobRemoved = await getFlipValue(contract, deployer);
+ expect(afterBobRemoved).to.be.eq(expectedFlipValue, `Bob can't call contract, now when he is removeed from white list.`);
+
+ await deployerCanFlip();
+
+ const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);
+ const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);
+ const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);
+ await submitTransactionAsync(bob, whiteListDisabledFlip);
+ expectedFlipValue = !expectedFlipValue;
+ const afterWhiteListDisabled = await getFlipValue(contract,deployer);
+ expect(afterWhiteListDisabled).to.be.eq(expectedFlipValue, `Anyone can call contract with disabled whitelist.`);
+
+ });
+ });
+
+ it(`Enabling white list repeatedly should not produce errors`, async () => {
+ await usingApi(async api => {
+ const [contract, deployer] = await deployFlipper(api);
+
+ const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+ const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);
+ const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);
+ const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+ const enableAgainEvents = await submitTransactionAsync(deployer, enableWhiteListTx);
+ const enabledAgain = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+
+ expect(getGenericResult(enableEvents).success).to.be.true;
+ expect(enabledBefore).to.be.false;
+ expect(enabled).to.be.true;
+ expect(getGenericResult(enableAgainEvents).success).to.be.true;
+ expect(enabledAgain).to.be.true;
+ });
+ });
+
+});
+
+describe('Negative Integration Test toggleContractWhiteList', () => {
+
+ it(`Enable white list for a non-contract`, async () => {
+ await usingApi(async api => {
+ const alice = privateKey("//Alice");
+ const bobGuineaPig = privateKey("//Bob");
+
+ const enabledBefore = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();
+ const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(bobGuineaPig.address, true);
+ await expect(submitTransactionExpectFailAsync(alice, enableWhiteListTx)).to.be.rejected;
+ const enabled = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();
+
+ expect(enabledBefore).to.be.false;
+ expect(enabled).to.be.false;
+ });
+ });
+
+ it(`Enable white list using a non-owner address`, async () => {
+ await usingApi(async api => {
+ const bob = privateKey("//Bob");
+ const [contract, deployer] = await deployFlipper(api);
+
+ const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+ const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);
+ await expect(submitTransactionExpectFailAsync(bob, enableWhiteListTx)).to.be.rejected;
+ const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();
+
+ expect(enabledBefore).to.be.false;
+ expect(enabled).to.be.false;
+ });
+ });
+
+});
tests/src/util/contracthelpers.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/util/contracthelpers.ts
@@ -0,0 +1,94 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from "chai";
+import chaiAsPromised from 'chai-as-promised';
+import { submitTransactionAsync } from "../substrate/substrate-api";
+import fs from "fs";
+import { Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract } from "@polkadot/api-contract";
+import { IKeyringPair } from "@polkadot/types/types";
+import { ApiPromise, Keyring } from "@polkadot/api";
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+import { BigNumber } from 'bignumber.js';
+import { findUnusedAddress } from '../util/helpers';
+
+const value = 0;
+const gasLimit = 3000n * 1000000n;
+const endowment = `1000000000000000`;
+
+function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<Blueprint> {
+ return new Promise<Blueprint>(async (resolve, reject) => {
+ const unsub = await code
+ .createBlueprint()
+ .signAndSend(alice, (result) => {
+ if (result.status.isInBlock || result.status.isFinalized) {
+ // here we have an additional field in the result, containing the blueprint
+ resolve(result.blueprint);
+ unsub();
+ }
+ })
+ });
+}
+
+function deployContract(alice: IKeyringPair, blueprint: Blueprint) : Promise<any> {
+ return new Promise<any>(async (resolve, reject) => {
+ const endowment = 1000000000000000n;
+ const initValue = true;
+
+ const unsub = await blueprint.tx
+ .new(endowment, gasLimit, initValue)
+ .signAndSend(alice, (result) => {
+ if (result.status.isInBlock || result.status.isFinalized) {
+ unsub();
+ resolve(result);
+ }
+ });
+ });
+}
+
+async function prepareDeployer(api: ApiPromise) {
+ // Find unused address
+ const deployer = await findUnusedAddress(api);
+
+ // Transfer balance to it
+ const keyring = new Keyring({ type: 'sr25519' });
+ const alice = keyring.addFromUri(`//Alice`);
+ let amount = new BigNumber(endowment);
+ amount = amount.plus(1e15);
+ const tx = api.tx.balances.transfer(deployer.address, amount.toFixed());
+ await submitTransactionAsync(alice, tx);
+
+ return deployer;
+}
+
+export async function deployFlipper(api: ApiPromise): Promise<[Contract, IKeyringPair]> {
+ const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));
+ const abi = new Abi(metadata);
+
+ const deployer = await prepareDeployer(api);
+
+ const wasm = fs.readFileSync('./src/flipper/flipper.wasm');
+
+ const code = new CodePromise(api, abi, wasm);
+
+ const blueprint = await deployBlueprint(deployer, code);
+ const contract = (await deployContract(deployer, blueprint))['contract'] as Contract;
+
+ const initialGetResponse = await getFlipValue(contract, deployer);
+ expect(initialGetResponse).to.be.true;
+
+ return [contract, deployer];
+}
+
+export async function getFlipValue(contract: Contract, deployer: IKeyringPair) {
+ const result = await contract.query.get(deployer.address, value, gasLimit);
+
+ if(!result.result.isSuccess) {
+ throw `Failed to get flipper value`;
+ }
+ return (result.result.asSuccess.data[0] == 0x00) ? false : true;
+}