为什么摩卡交易的测试结果是错误的,但它在 REST 测试中工作正常?
Why test result of a transaction in mocha is wrong but it work correctly in REST test?
我在 hyperledger-fabric
中写了一个事务,并在 mocha 上为它实现了一个测试单元。交易应设置资产的标题 属性。
在我使用 assetRegistry.updade
函数更新后,资产标题值没有改变,但是当我在 REST 中测试时它工作正常。
CTO 文件
transaction TestOnChat {
--> Chat chat
}
asset Chat identified by chatId {
o String chatId
o String title
o DateTime createAt
o ChatType type
o Member[] memberList
o Message[] messageList
}
permissions.asl
rule Test{
description: "Member can expel other member chat"
participant: "org.miluxas.chatnet2.User"
operation: ALL
resource: "org.miluxas.chatnet2.TestOnChat"
action: ALLOW
}
logic.js
/**
*
* @param {org.miluxas.chatnet2.TestOnChat} testOnChat - the teropooo
* @transaction
*/
async function testOnChat(ex){
ex.chat.title='fdfdfdf';
const memberRegistry = await getAssetRegistry('org.miluxas.chatnet2.Chat');
await memberRegistry.update(ex.chat);
}
test/logic.js
it('test chat', async () => {
// Use the identity for Solivan.
await useIdentity(solivanCardName);
await createNewChat('32556','first solivan group chat','PUBLIC_GROUP');
// Get the asset. and check if Ferzin added to chat
const assetRegistry = await businessNetworkConnection.getAssetRegistry('org.miluxas.chatnet2.Chat');
const asset1 = await assetRegistry.get('32556');
// Submit add other user to chat transaction
const transaction33 = factory.newTransaction(namespace, 'TestOnChat');
transaction33.chat = factory.newRelationship(namespace, 'Chat', '32556');
await businessNetworkConnection.submitTransaction(transaction33);
//console.log(asset1.type);
asset1.title.should.equal('fdfdfdf');
});
我在 test/logic.js
中发现了我的错误。我在提交TestOnChat transaction
之前设置了asset1
,提交交易后检查了
我在 hyperledger-fabric
中写了一个事务,并在 mocha 上为它实现了一个测试单元。交易应设置资产的标题 属性。
在我使用 assetRegistry.updade
函数更新后,资产标题值没有改变,但是当我在 REST 中测试时它工作正常。
CTO 文件
transaction TestOnChat {
--> Chat chat
}
asset Chat identified by chatId {
o String chatId
o String title
o DateTime createAt
o ChatType type
o Member[] memberList
o Message[] messageList
}
permissions.asl
rule Test{
description: "Member can expel other member chat"
participant: "org.miluxas.chatnet2.User"
operation: ALL
resource: "org.miluxas.chatnet2.TestOnChat"
action: ALLOW
}
logic.js
/**
*
* @param {org.miluxas.chatnet2.TestOnChat} testOnChat - the teropooo
* @transaction
*/
async function testOnChat(ex){
ex.chat.title='fdfdfdf';
const memberRegistry = await getAssetRegistry('org.miluxas.chatnet2.Chat');
await memberRegistry.update(ex.chat);
}
test/logic.js
it('test chat', async () => {
// Use the identity for Solivan.
await useIdentity(solivanCardName);
await createNewChat('32556','first solivan group chat','PUBLIC_GROUP');
// Get the asset. and check if Ferzin added to chat
const assetRegistry = await businessNetworkConnection.getAssetRegistry('org.miluxas.chatnet2.Chat');
const asset1 = await assetRegistry.get('32556');
// Submit add other user to chat transaction
const transaction33 = factory.newTransaction(namespace, 'TestOnChat');
transaction33.chat = factory.newRelationship(namespace, 'Chat', '32556');
await businessNetworkConnection.submitTransaction(transaction33);
//console.log(asset1.type);
asset1.title.should.equal('fdfdfdf');
});
我在 test/logic.js
中发现了我的错误。我在提交TestOnChat transaction
之前设置了asset1
,提交交易后检查了