Skip to content

Commit

Permalink
[FABN-1181] Sync up v2 channel config subdir
Browse files Browse the repository at this point in the history
Also update e2e tests due to fabtoken change

Change-Id: I2113ec2394ce630919cf171f209adb6c5d294c03
Signed-off-by: Wenjian Qiao <[email protected]>
  • Loading branch information
wenjianqiao committed Mar 18, 2019
1 parent dcaf7ca commit ebde2da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/integration/e2e/create-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ test('\n\n***** SDK Built config update create flow *****\n\n', async (t) => {
client.setCryptoSuite(cryptoSuite);

// use the config update created by the configtx tool
const channeltx_basename = process.env.channeltx_subdir ? path.join(process.env.channeltx_subdir, channel_name) : channel_name;
const envelope_bytes = fs.readFileSync(path.join(__dirname, '../../fixtures/crypto-material/channel-config', channeltx_basename + '.tx'));
const channeltx_subdir = process.env.channeltx_subdir ? process.env.channeltx_subdir : 'channel-config';
const envelope_bytes = fs.readFileSync(path.join(__dirname, '../../fixtures/crypto-material', channeltx_subdir, channel_name + '.tx'));
const config = client.extractChannelConfig(envelope_bytes);
t.pass('Successfully extracted the config update from the configtx envelope');

Expand Down
26 changes: 17 additions & 9 deletions test/integration/e2e/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ test('\n\n***** Token end-to-end flow (green path): issue, transfer, redeem and
});

test('\n\n***** Token end-to-end flow: double spending fails *****\n\n', async (t) => {
let transferToken;
try {
// create TokenClient for user1 (admin user in org1)
const user1ClientObj = await e2eUtils.createTokenClient('org1', channel_name, 'localhost:7051', t);
Expand Down Expand Up @@ -187,7 +188,7 @@ test('\n\n***** Token end-to-end flow: double spending fails *****\n\n', async (
logger.debug('\nuser1(org1) listed %d tokens after issue: \n%s', result.length, util.inspect(result, false, null));
validateTokens(result, [param], 'for user1 (owner) after issue', t);

const transferToken = result[0];
transferToken = result[0];

// build request for user1 to transfer transfer token to user2
txId = user1TokenClient.getClient().newTransactionID();
Expand Down Expand Up @@ -216,18 +217,23 @@ test('\n\n***** Token end-to-end flow: double spending fails *****\n\n', async (
};

// user1 transfers token again using the same tokenIds
result = await user1TokenClient.transfer(request);
await waitForTxEvent(eventhub, txId.getTransactionID(), 'INVALID_OTHER_REASON', t);

await user1TokenClient.transfer(request);
t.fail('Transfer should have failed due to double spending');
t.end();
} catch (err) {
logger.error(err);
t.fail('Failed to test token commands due to error: ' + err.stack ? err.stack : err);
const tokenId = '(' + transferToken.id.tx_id + ', ' + transferToken.id.index + ')';
t.equals(
err.message,
'command response has error: input TokenId ' + tokenId + ' does not exist or not owned by the user',
'Transfer failed as expected because token id has been spent and does not exist any more'
);
t.end();
}
});

test('\n\n***** Token end-to-end flow: non owner transfer fails *****\n\n', async (t) => {
let transferToken;

try {
// create TokenClient for user1 (admin user in org1)
// create TokenClient for user1 (admin user in org1)
Expand Down Expand Up @@ -268,7 +274,7 @@ test('\n\n***** Token end-to-end flow: non owner transfer fails *****\n\n', asyn
logger.debug('\nuser1(org1) listed %d tokens after issue: \n%s', result.length, util.inspect(result, false, null));
validateTokens(result, [param], 'for user1 (owner) after issue', t);

const transferToken = result[0];
transferToken = result[0];

// token is owned by user1, but user2 attempts to transfer the token, should fail
txId = user2TokenClient.getClient().newTransactionID();
Expand All @@ -287,10 +293,12 @@ test('\n\n***** Token end-to-end flow: non owner transfer fails *****\n\n', asyn
t.fail('');
t.end();
} catch (err) {
const tokenId = '(' + transferToken.id.tx_id + ', ' + transferToken.id.index + ')';
t.equals(
err.message,
'command response has error: the requestor does not own inputs',
'Transfer failed as expected because the requestor does not own the token');
'command response has error: input TokenId ' + tokenId + ' does not exist or not owned by the user',
'Transfer failed as expected because the requestor does not own the token'
);
t.end();
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/tokene2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Set env vars for the channel name and subdir for token e2e tests

process.env.channel = 'tokenchannel';
process.env.channeltx_subdir = 'v2';
process.env.channeltx_subdir = 'config-v2';

// Create and join the channel and then run token e2e tests
require('./e2e/create-channel.js');
Expand Down

0 comments on commit ebde2da

Please sign in to comment.