mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-02-02 14:44:27 +00:00
Merge pull request #1 from perissology/add_donor_on_donate
call addDonor in donate method if donorId is 0
This commit is contained in:
commit
c190d5fb0f
@ -21,7 +21,12 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
/// @param idDonor Identifier of the donor thats donating.
|
/// @param idDonor Identifier of the donor thats donating.
|
||||||
/// @param idReceiver To whom it's transfered. Can be the same donor, another
|
/// @param idReceiver To whom it's transfered. Can be the same donor, another
|
||||||
/// donor, a delegate or a project
|
/// 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);
|
NoteManager storage sender = findManager(idDonor);
|
||||||
|
|
||||||
checkManagerOwner(sender);
|
checkManagerOwner(sender);
|
||||||
|
@ -77,7 +77,7 @@ contract LiquidPledgingBase {
|
|||||||
|
|
||||||
/// @notice Creates a donor.
|
/// @notice Creates a donor.
|
||||||
function addDonor(string name, uint64 commitTime, ILiquidPledgingPlugin plugin
|
function addDonor(string name, uint64 commitTime, ILiquidPledgingPlugin plugin
|
||||||
) returns (uint64 idDonor) {//Todo return idManager
|
) returns (uint64 idDonor) {
|
||||||
|
|
||||||
idDonor = uint64(managers.length);
|
idDonor = uint64(managers.length);
|
||||||
|
|
||||||
@ -127,10 +127,10 @@ contract LiquidPledgingBase {
|
|||||||
false,
|
false,
|
||||||
plugin));
|
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
|
///@notice Changes the address, name or commitTime associated with a specific delegate
|
||||||
function updateDelegate(
|
function updateDelegate(
|
||||||
|
@ -42,6 +42,7 @@ describe('LiquidPledging test', () => {
|
|||||||
let liquidPledging;
|
let liquidPledging;
|
||||||
let vault;
|
let vault;
|
||||||
let donor1;
|
let donor1;
|
||||||
|
let donor2;
|
||||||
let delegate1;
|
let delegate1;
|
||||||
let adminProject1;
|
let adminProject1;
|
||||||
let adminProject2;
|
let adminProject2;
|
||||||
@ -57,10 +58,11 @@ describe('LiquidPledging test', () => {
|
|||||||
adminProject2 = accounts[4];
|
adminProject2 = accounts[4];
|
||||||
adminProject2a = accounts[5];
|
adminProject2a = accounts[5];
|
||||||
delegate2 = accounts[6];
|
delegate2 = accounts[6];
|
||||||
|
donor2 = accounts[7];
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Should deploy LiquidPledgin contract', async () => {
|
it('Should deploy LiquidPledging contract', async () => {
|
||||||
vault = await Vault.new(web3);
|
vault = await Vault.new(web3);
|
||||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5200000 });
|
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5200000 });
|
||||||
await vault.setLiquidPledging(liquidPledging.$address);
|
await vault.setLiquidPledging(liquidPledging.$address);
|
||||||
@ -300,4 +302,16 @@ describe('LiquidPledging test', () => {
|
|||||||
|
|
||||||
assert.equal(collected, 0.95);
|
assert.equal(collected, 0.95);
|
||||||
}).timeout(8000);
|
}).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);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user