Skip to content

sid226/fabric-java-sdk-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fabric-java-sdk-test

Testing Hyperledger java sdk

Prerequisites

  • MAVEN supported IDE
  • Docker

Run docker compose

#start CA container
docker-compose -f docker-compose-ca.yaml up -d
#stop CA container
docker-compose -f docker-compose-ca.yaml down

Run wallet test code :

  • Import Project

  • create user storage

   SampleUser user = sampleStore.getMember("user6", "org1");
  • run fabric-java-sdk-test\hyperledger wallet\src\main\java\com\github\maven\example\test.java to enroll admin

  • uncomment following to register user

    if (!user.isRegistered()) {  // users need to be registered AND enrolled
                //Register User with CA
                RegistrationRequest rr = new RegistrationRequest("user6", "org1.department1");
                String EnrollmentSecret=ca.register(rr, admin);
                System.out.println("Secret is "+EnrollmentSecret);

                user.setEnrollmentSecret(EnrollmentSecret);
                System.out.println("user.isRegistered()"+user.isRegistered());
            }
  • uncomment following to enroll user
    if (!user.isEnrolled()) {
                //Enroll user
                System.out.println("NOT enrolled");
                Enrollment enrollment = ca.enroll("user6", user.getEnrollmentSecret());
                System.out.println("enroll is "+enrollment.toString());
                user.setEnrollment(enrollment);
                user.setMspId("Org1MSP");
                System.out.println("user.isEnrolled()"+user.isEnrolled());
            }
  • View Certificate
System.out.println(("Certificate "+user.getEnrollment().getCert()));

About

Testing Hyperledger java sdk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages