Permalink
Browse files

Added InflationDest field.

Updated stellar-lib to latest version.
Added 'set InflationDest' and 'trust line' tests.
  • Loading branch information...
marco89nish committed Apr 30, 2014
1 parent 9418fa0 commit 1b669a8a6def4a3e29f3401be723c069b2c3c4fe
@@ -345,6 +345,7 @@ class SerializedTransactionTests : public UnitTest
j.setSourceAccount (publicAcct);
j.setSigningPubKey (publicAcct);
j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ());
j.setFieldAccount(sfInflationDest, publicAcct); //vote for yourself
j.sign (privateAcct);
unexpected (!j.checkSign (), "Transaction fails signature test");
@@ -276,6 +276,27 @@ TER AccountSetTransactor::doApply ()
}
}
//
// InflationDest
//
if ( mTxn.isFieldPresent(sfInflationDest) )
{
RippleAddress aInflationDest = mTxn.getFieldAccount(sfInflationDest);
if (!mEngine->getLedger()->hasAccount(aInflationDest))
{
WriteLog(lsINFO, AccountSetTransactor) << "AccountSet: Inflation destination account doesn't exist.";
return temDST_NEEDED;
}
mTxnAccount->setFieldAccount(sfInflationDest, aInflationDest);
}
//
// TransferRate
//
@@ -34,6 +34,7 @@ LedgerFormats::LedgerFormats ()
<< SOElement (sfMessageKey, SOE_OPTIONAL)
<< SOElement (sfTransferRate, SOE_OPTIONAL)
<< SOElement (sfDomain, SOE_OPTIONAL)
<< SOElement (sfInflationDest, SOE_OPTIONAL)
;
add ("Contract", ltCONTRACT)
@@ -170,6 +170,7 @@ FIELD (Destination, ACCOUNT, 3)
FIELD (Issuer, ACCOUNT, 4)
FIELD (Target, ACCOUNT, 7)
FIELD (RegularKey, ACCOUNT, 8)
FIELD (InflationDest, ACCOUNT, 9)
// path set
FIELD (Paths, PATHSET, 1)
@@ -28,6 +28,7 @@ TxFormats::TxFormats ()
<< SOElement (sfTransferRate, SOE_OPTIONAL)
<< SOElement (sfSetFlag, SOE_OPTIONAL)
<< SOElement (sfClearFlag, SOE_OPTIONAL)
<< SOElement (sfInflationDest, SOE_OPTIONAL)
;
add ("TrustSet", ttTRUST_SET)
View
@@ -15,6 +15,35 @@ suite('Account set', function() {
testutils.build_teardown().call($, done);
});
test('set InflationDest', function(done) {
var self = this;
var steps = [
function (callback) {
self.what = "Set InflationDest.";
$.remote.transaction()
.account_set("root")
.inflation_dest($.remote.account('root')._account_id)
.on('submitted', function (m) {
//console.log("proposed: %s", JSON.stringify(m));
if (m.engine_result === 'tesSUCCESS') {
callback(null);
} else {
callback(new Error(m.engine_result));
}
})
.submit();
}
]
async.waterfall(steps,function (error) {
assert(!error, self.what);
done();
});
});
test('set RequireDestTag', function(done) {
var self = this;
View
@@ -11,7 +11,7 @@ assert = require 'assert'
Base
Transaction
sjcl
} = require 'ripple-lib'
} = require 'stellar-lib'
{Server} = require './server'
testutils = require './testutils'
View
@@ -458,6 +458,82 @@ suite('Gateway', function() {
testutils.build_teardown().call($, done);
});
test("trust line", function (done) {
var self = this;
var steps = [
function (callback) {
self.what = "Create accounts.";
testutils.create_accounts($.remote, "root", "10000.0", ["alice", "bob", "mtgox", "bitstamp", "amazon"], callback);
},
function (callback) {
self.what = "Set credit limits.";
testutils.credit_limits($.remote, {
"alice" : [ "100/BTC/amazon", "100/BTC/bitstamp", "100/BTC/mtgox", ] ,
"bob" : "100/BTC/amazon",
},
callback);
},
function (callback) {
self.what = "Distribute funds.";
testutils.payments($.remote, {
"mtgox" : [ "5/BTC/alice" ],
"bitstamp" : [ "5/BTC/alice" ],
"amazon" : [ "5/BTC/alice" ],
},
callback);
},
function (callback) {
self.what = "Verify balances.";
testutils.verify_balances($.remote, {
"alice" : ["5/BTC/mtgox", "5/BTC/bitstamp", "5/BTC/amazon", ],
"amazon" : "-5/BTC/alice",
},
callback);
},
function (callback) {
self.what = "Alice sends Bob 3 BTC";
$.remote.transaction()
.payment("alice", "bob", "3/BTC/bob")
.build_path(true)
.once('proposed', function (m) {
callback(m.engine_result !== 'tesSUCCESS');
})
.submit();
},
function (callback) {
self.what = "Verify balances 2.";
testutils.verify_balances($.remote, {
"alice" : ["2/BTC/amazon", "5/BTC/mtgox", "5/BTC/bitstamp", ],
"bob" : "3/BTC/amazon",
"amazon" : ["-3/BTC/bob", "-2/BTC/alice"],
},
callback);
},
]
async.waterfall(steps, function(error) {
assert(!error, self.what);
done();
});
});
test("customer to customer with and without transfer fee", function (done) {
var self = this;

0 comments on commit 1b669a8

Please sign in to comment.