|
From: <pe...@us...> - 2003-10-28 23:42:51
|
Update of /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/pay/receiver
In directory sc8-pr-cvs1:/tmp/cvs-serv8452/src/test/org/neuclear/pay/receiver
Modified Files:
PaymentReceiverTest.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: PaymentReceiverTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/pay/receiver/PaymentReceiverTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PaymentReceiverTest.java 25 Oct 2003 00:46:29 -0000 1.1
--- PaymentReceiverTest.java 28 Oct 2003 23:42:47 -0000 1.2
***************
*** 5,10 ****
--- 5,13 ----
import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.ledger.BookExistsException;
import org.neuclear.ledger.LedgerCreationException;
import org.neuclear.ledger.LowlevelLedgerException;
+ import org.neuclear.ledger.UnknownBookException;
+ import org.neuclear.pay.Account;
import org.neuclear.pay.PaymentProcessor;
import org.neuclear.pay.contracts.TransferContract;
***************
*** 33,36 ****
--- 36,43 ----
$Id$
$Log$
+ Revision 1.2 2003/10/28 23:42:47 pelle
+ The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ The two SignerStore implementations both use it for the passphrase.
+
Revision 1.1 2003/10/25 00:46:29 pelle
Added tests to test the PaymentReceiver.
***************
*** 47,51 ****
public PaymentReceiverTest(String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
! //proc=PaymentProcessor.getInstance();
receiver = new PaymentReceiver(proc, "neu://test/pay");
}
--- 54,58 ----
public PaymentReceiverTest(String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
! proc = PaymentProcessor.getInstance();
receiver = new PaymentReceiver(proc, "neu://test/pay");
}
***************
*** 63,72 ****
}
public Object getPreTransactionState(SignedNamedObject obj) throws Exception {
if (obj instanceof TransferContract) {
TransferContract transfer = (TransferContract) obj;
! double fromBalance = proc.getAccount(transfer.getSignatory().getName()).getBalance(transfer.getTimeStamp());
! double toBalance = proc.getAccount(transfer.getRecipient()).getBalance(transfer.getTimeStamp());
return new double[]{fromBalance, toBalance};
--- 70,91 ----
}
+ private Account createNewAccount(String name) throws BookExistsException, LowlevelLedgerException {
+ try {
+ return proc.getAccount(name);
+ } catch (UnknownBookException e) {
+ return proc.createAccount(name, name);
+ }
+
+ }
+
public Object getPreTransactionState(SignedNamedObject obj) throws Exception {
if (obj instanceof TransferContract) {
TransferContract transfer = (TransferContract) obj;
! Account fromAccount = createNewAccount(transfer.getSignatory().getName());
! double fromBalance = (fromAccount != null) ? fromAccount.getBalance(transfer.getTimeStamp()) : 0;
! Account toAccount = createNewAccount(transfer.getRecipient());
! double toBalance = (toAccount != null) ? toAccount.getBalance(transfer.getTimeStamp()) : 0;
! ;
return new double[]{fromBalance, toBalance};
***************
*** 79,84 ****
TransferContract transfer = (TransferContract) obj;
final double prebalances[] = (double[]) state;
! double fromBalance = proc.getAccount(transfer.getSignatory().getName()).getBalance(transfer.getTimeStamp());
! double toBalance = proc.getAccount(transfer.getRecipient()).getBalance(transfer.getTimeStamp());
return (fromBalance == prebalances[0] - transfer.getAmount()) &&
--- 98,106 ----
TransferContract transfer = (TransferContract) obj;
final double prebalances[] = (double[]) state;
! Account fromAccount = createNewAccount(transfer.getSignatory().getName());
! Account toAccount = createNewAccount(transfer.getRecipient());
! double fromBalance = (fromAccount != null) ? fromAccount.getBalance(transfer.getTimeStamp()) : 0;
! double toBalance = (toAccount != null) ? toAccount.getBalance(transfer.getTimeStamp()) : 0;
! ;
return (fromBalance == prebalances[0] - transfer.getAmount()) &&
|