Merge branch 'master' of github.com:Giveth/liquidpledging

This commit is contained in:
Jordi Baylina 2017-10-03 11:51:26 +02:00
commit 3e945ff349
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
4 changed files with 26 additions and 7 deletions

View File

@ -21,7 +21,12 @@ contract LiquidPledging is LiquidPledgingBase {
/// @param idDonor Identifier of the donor thats donating.
/// @param idReceiver To whom it's transfered. Can be the same donor, another
/// donor, a delegate or a project
function donate(uint64 idDonor, uint64 idReceiver) payable {
function donate(uint64 idDonor, uint64 idReceiver) payable {
if (idDonor == 0) {
idDonor = addDonor('', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime
}
NoteManager storage sender = findManager(idDonor);
checkManagerOwner(sender);

View File

@ -77,7 +77,7 @@ contract LiquidPledgingBase {
/// @notice Creates a donor.
function addDonor(string name, uint64 commitTime, ILiquidPledgingPlugin plugin
) returns (uint64 idDonor) {//Todo return idManager
) returns (uint64 idDonor) {
idDonor = uint64(managers.length);
@ -127,10 +127,10 @@ contract LiquidPledgingBase {
false,
plugin));
DeegateAdded(idDelegate);
DelegateAdded(idDelegate);
}
event DeegateAdded(uint64 indexed idDelegate);
event DelegateAdded(uint64 indexed idDelegate);
///@notice Changes the address, name or commitTime associated with a specific delegate
function updateDelegate(

View File

@ -34,7 +34,7 @@ contract Vault is Owned {
/// funds transparently by its connection to other `Payment` structs
struct Payment {
PaymentState state; //
bytes32 ref; // a hash that references details from other contracts
bytes32 ref; // an input that references details from other contracts
address dest; // recipient of the ETH
uint amount; // amount of ETH (in wei) to be sent
}
@ -58,6 +58,7 @@ contract Vault is Owned {
}
function setLiquidPledging(address _newLiquidPledging) onlyOwner {
require(address(liquidPledging) == 0x0);
liquidPledging = LiquidPledging(_newLiquidPledging);
}
@ -134,5 +135,4 @@ contract Vault is Owned {
event ConfirmPayment(uint indexed idPayment);
event CancelPayment(uint indexed idPayment);
event AuthorizePayment(uint indexed idPayment, bytes32 indexed ref, address indexed dest, uint amount);
}

View File

@ -42,6 +42,7 @@ describe('LiquidPledging test', () => {
let liquidPledging;
let vault;
let donor1;
let donor2;
let delegate1;
let adminProject1;
let adminProject2;
@ -57,10 +58,11 @@ describe('LiquidPledging test', () => {
adminProject2 = accounts[4];
adminProject2a = accounts[5];
delegate2 = accounts[6];
donor2 = accounts[7];
done();
});
});
it('Should deploy LiquidPledgin contract', async () => {
it('Should deploy LiquidPledging contract', async () => {
vault = await Vault.new(web3);
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5200000 });
await vault.setLiquidPledging(liquidPledging.$address);
@ -300,4 +302,16 @@ describe('LiquidPledging test', () => {
assert.equal(collected, 0.95);
}).timeout(8000);
it('Should make a donation and create donor', async () => {
await liquidPledging.donate(0, 1, { from: donor2, value: web3.toWei(1) });
const nNotes = await liquidPledging.numberOfNotes();
assert.equal(nNotes.toNumber(), 14);
const nManagers = await liquidPledging.numberOfNoteManagers();
assert.equal(nManagers.toNumber(), 7);
const res = await liquidPledging.getNoteManager(7);
assert.equal(res[0], 0); // Donor
assert.equal(res[1], donor2);
assert.equal(res[2], '');
assert.equal(res[3], 259200); // default to 3 day commitTime
}).timeout(6000);
});