Skip to content
Permalink
Browse files

swap: fixed validation of subtransactions

  • Loading branch information...
Aleksandr-Starun committed Jul 19, 2019
1 parent 04b244a commit dc2ba647f471d34cf1656373333b3db83e830a9d
Showing with 8 additions and 4 deletions.
  1. +2 −0 wallet/swaps/swap_transaction.cpp
  2. +6 −4 wallet/unittests/swap_test.cpp
@@ -781,6 +781,7 @@ namespace beam::wallet
auto transaction = lockTxBuilder->CreateTransaction();
TxBase::Context::Params pars;
TxBase::Context context(pars);
context.m_Height.m_Min = lockTxBuilder->GetMinHeight();
if (!transaction->IsValid(context))
{
OnSubTxFailed(TxFailureReason::InvalidTransaction, SubTxIndex::BEAM_LOCK_TX, true);
@@ -931,6 +932,7 @@ namespace beam::wallet
auto transaction = builder.CreateTransaction();
TxBase::Context::Params pars;
TxBase::Context context(pars);
context.m_Height.m_Min = builder.GetMinHeight();
if (!transaction->IsValid(context))
{
OnSubTxFailed(TxFailureReason::InvalidTransaction, subTxID, true);
@@ -127,7 +127,7 @@ namespace
}
}

void TestSwapTransaction(bool isBeamOwnerStart)
void TestSwapTransaction(bool isBeamOwnerStart, beam::Height fork1Height)
{
cout << "\nTesting atomic swap transaction...\n";

@@ -181,7 +181,7 @@ void TestSwapTransaction(bool isBeamOwnerStart)
NodeObserver observer([&]()
{
auto cursor = node.get_Processor().m_Cursor;
if (cursor.m_Sid.m_Height == 5)
if (cursor.m_Sid.m_Height == fork1Height + 5)
{
if (isBeamOwnerStart)
{
@@ -747,9 +747,11 @@ int main()
auto logger = beam::Logger::create(logLevel, logLevel);
Rules::get().FakePoW = true;
Rules::get().UpdateChecksum();
beam::Height fork1Height = 10;
Rules::get().pForks[1].m_Height = fork1Height;

TestSwapTransaction(true);
TestSwapTransaction(false);
TestSwapTransaction(true, fork1Height);
TestSwapTransaction(false, fork1Height);
TestSwapTransactionWithoutChange(true);

TestSwapBTCRefundTransaction();

0 comments on commit dc2ba64

Please sign in to comment.
You can’t perform that action at this time.