如何在没有键值存储或钱包的情况下强制设置用户上下文?

How do I force set the user context without a key value store or wallet?

出于测试目的,我手头已经有了 public 密钥 + 私钥 + 证书(可以硬编码),我可以通过连接配置文件设置 CA,但我将如何调用没有设置文件系统键值 store/wallet 的事务?

使用 InMemoryWallet class - 参见 https://fabric-sdk-node.github.io/master/module-fabric-network.InMemoryWallet.html

示例:

 const credPath = '/home/demo/mynetwork/crypto-material/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp';
 const cert = fs.readFileSync(credPath + '/cert.pem').toString();
 const key = fs.readFileSync(credPath + '/key.pem').toString();
 const inMemoryWallet = new InMemoryWallet();
 await inMemoryWallet.import('admin', X509WalletMixin.createIdentity('Org1MSP', cert, key));

或查看 integration test scripts for Fabric Node SDK