update
This commit is contained in:
parent
e65687aa9b
commit
3e3492254e
Binary file not shown.
|
@ -21,13 +21,13 @@ public class Config {
|
|||
|
||||
|
||||
//CA
|
||||
//public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
||||
public static final String CA_ORG1_URL = "http://93.30.148.59:7054";
|
||||
public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
||||
//public static final String CA_ORG1_URL = "http://93.30.148.59:7054";
|
||||
//public static final String CA_ORG1_URL = "http://vps592802.ovh.net:7054";
|
||||
|
||||
//ORDERER
|
||||
//public static final String ORDERER_URL = "grpc://vps577432.ovh.net:7050";
|
||||
public static final String ORDERER_URL = "grpc://93.30.148.59:7050";
|
||||
public static final String ORDERER_URL = "grpc://vps577432.ovh.net:7050";
|
||||
//public static final String ORDERER_URL = "grpc://93.30.148.59:7050";
|
||||
//public static final String ORDERER_URL = "grpc://vps592802.ovh.net:7050";
|
||||
|
||||
public static final String ORDERER_NAME = "orderer.example.com";
|
||||
|
@ -35,14 +35,15 @@ public class Config {
|
|||
//CHANNEL - CHAINCODE
|
||||
public static final String CHANNEL_NAME = "mychannel";
|
||||
|
||||
public static final String CHAINCODE_NAME = "monnethic";
|
||||
//public static final String CHAINCODE_NAME = "monnethic";
|
||||
public static final String CHAINCODE_NAME = "monnethic_qa";
|
||||
//public static final String CHAINCODE_PROD = "monnethic-prod";
|
||||
|
||||
//PEER 0
|
||||
public static final String ORG1_PEER_0 = "peer0.org1.example.com";
|
||||
|
||||
//public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:8051";
|
||||
public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:7051";
|
||||
public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:7051";
|
||||
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:7051";
|
||||
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:8051";
|
||||
//ublic static final String ORG1_PEER_0_URL = "grpc://vps592802.ovh.net:7051";
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
|||
import com.j256.ormlite.support.ConnectionSource;
|
||||
|
||||
public class DatabaseHelper {
|
||||
private static final String DATABASE_NAME = "monnethic_test";
|
||||
//private static final String DATABASE_NAME = "monnethic_test";
|
||||
private static final String DATABASE_NAME = "monnethic_qa";
|
||||
private static final String DATABASE_USER = "monnethicadmin";
|
||||
private static final String DATABASE_PWD = "vHEQszGXcJ6;/)}z!V";
|
||||
private final static String DATABASE_URL = "jdbc:postgresql://37.187.101.44:5432/"+DATABASE_NAME;
|
||||
|
|
|
@ -86,9 +86,12 @@ public class WalletImplementation {
|
|||
User association = userDao.getUserWithHash(associationHash);
|
||||
if(association != null){
|
||||
System.out.println("CHECK PWD");
|
||||
if(BCrypt.checkpw(associationPwd, association.getPassword())){
|
||||
|
||||
if(BCrypt.checkpw(associationPwd, association.getPassword())){
|
||||
System.out.println("OK");
|
||||
double newBalance = 0.0;
|
||||
System.out.println("walletHash : "+walletHash);
|
||||
System.out.println("amount : "+amount);
|
||||
transactionWrapper.sendTransaction("setBalanceOnWallet",new String[]{walletHash,String.valueOf(amount)});
|
||||
Wallet wallet = getWallet(walletHash);
|
||||
if(wallet!=null){
|
||||
|
|
|
@ -2,7 +2,7 @@ package restService;
|
|||
|
||||
public class StringResponse {
|
||||
private String response;
|
||||
private String userHash;
|
||||
private String user_hash;
|
||||
private Double userBalance;
|
||||
|
||||
public StringResponse(String response){
|
||||
|
@ -16,7 +16,7 @@ public class StringResponse {
|
|||
|
||||
public StringResponse(String response, String userHash){
|
||||
this.response=response;
|
||||
this.userHash=userHash;
|
||||
this.user_hash=userHash;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
|
@ -28,11 +28,11 @@ public class StringResponse {
|
|||
}
|
||||
|
||||
public String getUserHash() {
|
||||
return userHash;
|
||||
return user_hash;
|
||||
}
|
||||
|
||||
public void setUserHash(String userHash) {
|
||||
this.userHash = userHash;
|
||||
this.user_hash = userHash;
|
||||
}
|
||||
|
||||
public Double getUserBalance(){return userBalance;}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class UserResource {
|
|||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> login(@Valid @RequestBody User user){
|
||||
public ResponseEntity login(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Map<String,String> response = userImplementation.userLogger(user);
|
||||
|
@ -72,8 +72,9 @@ public class UserResource {
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
||||
}
|
||||
case "true":{
|
||||
StringResponse responseS = new StringResponse("Ok",response.get("user_hash"));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
||||
//StringResponse responseS = new StringResponse("Ok",response.get("user_hash"));
|
||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+response.get("user_hash")+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}
|
||||
default:{
|
||||
StringResponse responseS = new StringResponse("Error");
|
||||
|
|
|
@ -22,11 +22,12 @@ public class ReadUserTest {
|
|||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "readUser";
|
||||
String[] args = new String[]{"$2a$10$wKfsus5O9C8.CI8JZxqeweSAzxgEOYpdaoRoHi85w05cGYGyDqTYK"};
|
||||
String[] args = new String[]{"$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
if(response != null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject userInfo = reader.readObject();
|
||||
logger.info(userInfo.toString());
|
||||
logger.info("userAssociation : "+userInfo.getString("userAssociation"));
|
||||
logger.info("userFirstName : "+userInfo.getString("userFirstName"));
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,8 @@ public class QueryWalletByOwnerTest {
|
|||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "queryWalletsByOwner";
|
||||
String[] args = new String[]{"$2a$10$2H6rEnTlEUBk18xUjXx5YuTmgiUMtyRdxgTjfugVlAcZbtDfPiWky"};
|
||||
//String[] args = new String[]{"$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC"};
|
||||
String[] args = new String[]{"$2a$10$nXjf7raNTCe2gdUiMCsNEegqUBQ6iihgc8LtoBUux02hL8j49b1rG"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
logger.info("response : "+response);
|
||||
|
||||
|
@ -38,6 +39,7 @@ public class QueryWalletByOwnerTest {
|
|||
o = o.get("Record").asJsonObject();
|
||||
logger.info("JsonObject : "+o);
|
||||
logger.info("walletInfo ID : "+o.getString("id"));
|
||||
logger.info("walletInfo balance : "+o.getJsonNumber("balance"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,40 +20,55 @@ public class CreateDataSetProcess { //OK
|
|||
private static String walletHash2UserB = "";
|
||||
|
||||
public static void main(String [ ] args){
|
||||
|
||||
BasicConfigurator.configure();
|
||||
User association = new User("Gonette","Association","gonette-lyon@gmail.com","asso_GonE8977&4$*-","gonette");
|
||||
User userA = new User("Meunier","Thomas","thomas.meunier@gmail.com","thomasPwd158$*","gonette");
|
||||
User userB = new User("Petit","Claire","claire.petit@gmail.com","gonClaire789$*","0607080900","gonette");
|
||||
|
||||
|
||||
String assoPwd = association.getPassword();
|
||||
String userBPwd = userB.getPassword();
|
||||
|
||||
|
||||
/*
|
||||
registerUser(association);
|
||||
association.setUser_hash(gonetteHash);
|
||||
registerUser(userA);
|
||||
userA.setUser_hash(userHashA);
|
||||
registerUser(userB);
|
||||
userB.setUser_hash(userHashB);
|
||||
*/
|
||||
|
||||
approveUser(userA);
|
||||
approveUser(userB);
|
||||
|
||||
Wallet walletAUserA = new Wallet("client",userHashA);
|
||||
Wallet walletBUserA = new Wallet("fournisseur",userHashA);
|
||||
Wallet walletAUserB = new Wallet("client",userHashB);
|
||||
Wallet walletBUserB = new Wallet("personnel",userHashB);
|
||||
|
||||
createWallet(walletAUserA);
|
||||
createWallet(walletBUserA);
|
||||
createWallet(walletAUserB);
|
||||
createWallet(walletBUserB);
|
||||
userA.setUser_hash("$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC");
|
||||
userB.setUser_hash("$2a$10$nXjf7raNTCe2gdUiMCsNEegqUBQ6iihgc8LtoBUux02hL8j49b1rG");
|
||||
association.setUser_hash("$2a$10$otvlv9oGEbnOPuImSJDDw.XDb3Bl7TR/Qw7w1HIfX0je11R/0leiS");
|
||||
//approveUser(userA);
|
||||
//approveUser(userB);
|
||||
//approveUser(association);
|
||||
|
||||
|
||||
setBalance(association.getUser_hash(), assoPwd, walletBUserA.getWallet_hash(),120);
|
||||
setBalance(association.getUser_hash(), assoPwd, walletAUserB.getWallet_hash(),50);
|
||||
Wallet walletAUserA = new Wallet("client",userA.getUser_hash());
|
||||
Wallet walletBUserA = new Wallet("fournisseur",userA.getUser_hash());
|
||||
Wallet walletAUserB = new Wallet("client",userB.getUser_hash());
|
||||
Wallet walletBUserB = new Wallet("personnel",userB.getUser_hash());
|
||||
|
||||
//String wHash1 = createWallet(walletAUserA);
|
||||
//walletAUserA.setWallet_hash(wHash1);
|
||||
//String wHash2 = createWallet(walletBUserA);
|
||||
//walletBUserA.setWallet_hash(wHash2);
|
||||
//String wHash3 = createWallet(walletAUserB);
|
||||
//walletAUserB.setWallet_hash(wHash3);
|
||||
//String wHash4 = createWallet(walletBUserB);
|
||||
//walletBUserB.setWallet_hash(wHash4);
|
||||
walletBUserA.setWallet_hash("$2a$10$dmrOFohMnbeVzVHMGc5JnuQ7MMTObn3lHTrMSe/IonD3VTeM.muo.");
|
||||
walletAUserB.setWallet_hash("$2a$10$auM7V8D0EuftV.2TqzWgi.4MIw0EzSJ8JyE5F5GzKknzqnila.EUm");
|
||||
|
||||
|
||||
|
||||
//setBalance(association.getUser_hash(), assoPwd, walletBUserA.getWallet_hash(),120);
|
||||
//setBalance(association.getUser_hash(), assoPwd, walletAUserB.getWallet_hash(),50);
|
||||
|
||||
doTransaction(userB.getUser_hash(), userBPwd, walletAUserB.getWallet_hash(),walletBUserA.getWallet_hash(),10,userB.getAssociation());
|
||||
|
||||
}
|
||||
|
||||
private static void registerUser(User user){
|
||||
|
@ -87,30 +102,35 @@ public class CreateDataSetProcess { //OK
|
|||
}
|
||||
}
|
||||
|
||||
private static void createWallet(Wallet wallet){
|
||||
|
||||
private static String createWallet(Wallet wallet){
|
||||
String wHash="";
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Map<String,String> walletResponse = walletImplementation.createWallet(wallet);
|
||||
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
||||
if(wallet.getUser_hash().equals(userHashA) && wallet.getType().equals("client")){
|
||||
walletHash1UserA = walletResponse.get("walletHash");
|
||||
walletHash1UserA = walletResponse.getWallet_hash();
|
||||
} else if(wallet.getUser_hash().equals(userHashA) && wallet.getType().equals("fournisseur")){
|
||||
walletHash2UserA = walletResponse.get("walletHash");
|
||||
walletHash2UserA = walletResponse.getWallet_hash();
|
||||
} else if(wallet.getUser_hash().equals(userHashB) && wallet.getType().equals("personnel")){
|
||||
walletHash1UserB = walletResponse.get("walletHash");
|
||||
walletHash1UserB = walletResponse.getWallet_hash();
|
||||
} else {
|
||||
walletHash2UserB = walletResponse.get("walletHash");
|
||||
walletHash2UserB = walletResponse.getWallet_hash();
|
||||
}
|
||||
|
||||
logger.info("wallet hash: "+walletResponse.get("walletHash"));
|
||||
logger.info("wallet balance: "+walletResponse.get("walletBalance"));
|
||||
logger.info("wallet type: "+walletResponse.get("walletType"));
|
||||
logger.info("onwer: "+walletResponse.get("ownerHash"));
|
||||
logger.info("wallet hash: "+walletResponse.getWallet_hash());
|
||||
logger.info("wallet balance: "+walletResponse.getBalance());
|
||||
logger.info("wallet type: "+walletResponse.getType());
|
||||
logger.info("onwer: "+walletResponse.getUser_hash());
|
||||
|
||||
wHash = walletResponse.getWallet_hash();
|
||||
}catch (Exception e){
|
||||
logger.warn("Error approveUser : "+e);
|
||||
}
|
||||
return wHash;
|
||||
}
|
||||
|
||||
|
||||
private static void setBalance(String associationHash, String associationPwd, String walletHash, double amount){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
public class WalletImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(WalletImplementationTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void CreateWalletTest() { // OK
|
||||
BasicConfigurator.configure();
|
||||
|
@ -32,6 +33,7 @@ public class WalletImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void TestDeleteWallet() { //OK
|
||||
|
|
Loading…
Reference in a new issue