53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
package blockchain.query.Wallet;
|
|
|
|
import blockchain.client.ChannelClientWrapper;
|
|
import blockchain.client.FabricClientWrapper;
|
|
import blockchain.configuration.Config;
|
|
import blockchain.query.QueryTest;
|
|
import blockchain.user.UserContext;
|
|
import blockchain.utility.Util;
|
|
import org.apache.log4j.BasicConfigurator;
|
|
import org.apache.log4j.Logger;
|
|
import org.hyperledger.fabric.sdk.ChaincodeResponse;
|
|
import org.hyperledger.fabric.sdk.ProposalResponse;
|
|
import org.junit.Ignore;
|
|
import org.junit.Test;
|
|
|
|
import java.util.Collection;
|
|
|
|
@Ignore
|
|
public class ReadWalletTest {
|
|
private static Logger logger = Logger.getLogger(ReadWalletTest.class);
|
|
|
|
@Test
|
|
public void TestQueryWallet() {
|
|
BasicConfigurator.configure();
|
|
UserContext user = Util.readUserContext(Config.ORG1,"admin");
|
|
|
|
try{
|
|
String chaincode = Config.CHAINCODE_NAME;
|
|
FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(user);
|
|
|
|
ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper);
|
|
|
|
//String[] args1 = {"qerh654d5f5h46q4fdh6h65fh2"};
|
|
String[] args1 = {"qerh654d5f5h46q4fdh6h65fh00"};
|
|
//String[] args1 = {"qerh654d5f5h46q4fdh6h65fh01"};
|
|
Collection<ProposalResponse> responseQuery = channelClientWrapper.queryByChainCode(chaincode,"readWallet",args1);
|
|
|
|
for(ProposalResponse pres : responseQuery){
|
|
ChaincodeResponse.Status status = pres.getStatus();
|
|
if(status.getStatus()!=200){
|
|
throw new Exception(pres.getMessage());
|
|
}
|
|
String stringResponse = new String(pres.getChaincodeActionResponsePayload());
|
|
logger.info("RESPONSE : "+stringResponse);
|
|
}
|
|
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
}
|