Skip to content

Commit

Permalink
[test] refs #4 Repair error in coin_TransactionTest Tests run: 77, Fa…
Browse files Browse the repository at this point in the history
…ilures: 0, Errors: 0, Skipped: 0
  • Loading branch information
Maykel Arias Torres committed Dec 9, 2018
1 parent 5d9185b commit bf4467d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 61 deletions.
103 changes: 50 additions & 53 deletions src/test/java/skycoin/libjava/coin_transactionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,103 +555,100 @@ public void TestTransactionsHashes() {
@Test

public void TestTransactionsTruncateBytesTo() {
SWIGTYPE_p_Transactions__Handle handles = new_Transactions__HandlePtr();
long err = makeTransactions(10, handles);
long trunc = (long)0;
SWIGTYPE_p_unsigned_int count = new_GoUint32Ptr();
SWIGTYPE_p_Transactions__Handle handles = new_Transactions__HandlePtr ();
long err = makeTransactions (10, handles);
int trunc = 0;
SWIGTYPE_p_unsigned_int count = new_GoUint32Ptr ();
SWIGTYPE_p_long_long len_tnxs = new_GointPtr();
err = SKY_coin_Transactions_Length(handles, len_tnxs);
err = SKY_coin_Transactions_Length (handles, len_tnxs);
long len_tnxs_value = GointPtr_value(len_tnxs);
for (long i = 0; i < (len_tnxs_value / 2); i++) {
count = new_GoUint32Ptr();
SWIGTYPE_p_Transaction__Handle handle = new_Transaction__HandlePtr();
err = SKY_coin_Transactions_GetAt(handles, (long)i, handle);
assertEquals(err, SKY_OK);
err = SKY_coin_Transaction_Size(handle, count);
assertEquals(err, SKY_OK);
trunc += GoUint32Ptr_value(count);
count = new_GoUint32Ptr ();
SWIGTYPE_p_Transaction__Handle handle = new_Transaction__HandlePtr();
err = SKY_coin_Transactions_GetAt (handles, (long) i, handle);
assertEquals(err, SKY_OK);
err = SKY_coin_Transaction_Size (handle, count);
assertEquals(err, SKY_OK);
trunc += GoUint32Ptr_value (count);
}
// Trucating halfway
SWIGTYPE_p_Transactions__Handle tnxs2 = new_Transactions__HandlePtr();
err = SKY_coin_Transactions_TruncateBytesTo(handles, trunc, tnxs2);
SWIGTYPE_p_Transactions__Handle tnxs2 = new_Transactions__HandlePtr ();
err = SKY_coin_Transactions_TruncateBytesTo (handles, trunc, tnxs2);
assertEquals(err, SKY_OK);
SWIGTYPE_p_long_long len_tnxs2 = new_GointPtr();

err = SKY_coin_Transactions_Length(tnxs2, len_tnxs2);
err = SKY_coin_Transactions_Length (tnxs2, len_tnxs2);
assertEquals(err, SKY_OK);

assertEquals(err, SKY_OK);
assertEquals(GointPtr_value(len_tnxs2), len_tnxs_value / 2);
count = new_GoUint32Ptr();
err = SKY_coin_Transactions_Size(tnxs2, count);
count = new_GoUint32Ptr ();
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), trunc);
assertEquals(GoUint32Ptr_value (count), trunc);

// Stepping into next boundary has same cutoff, must exceed
trunc += 1;
err = SKY_coin_Transactions_TruncateBytesTo(handles, trunc, tnxs2);
err = SKY_coin_Transactions_TruncateBytesTo (handles, trunc, tnxs2);
assertEquals(err, SKY_OK);
SWIGTYPE_p_long_long len = new_GointPtr();
err = SKY_coin_Transactions_Length(tnxs2, len);
err = SKY_coin_Transactions_Length (tnxs2, len);
assertEquals(err, SKY_OK);
assertEquals(GointPtr_value(len), len_tnxs_value / 2);
err = SKY_coin_Transactions_Size(tnxs2, count);
assertEquals(GointPtr_value (len), len_tnxs_value / 2);
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), trunc - 1);
assertEquals(GoUint32Ptr_value (count), trunc - 1);

// Moving to 1 before next level
SWIGTYPE_p_Transaction__Handle tnxs_5 = utils.makeEmptyTransaction();
err = SKY_coin_Transactions_GetAt(handles, 5, tnxs_5);
SWIGTYPE_p_Transaction__Handle tnxs_5 = utils.makeEmptyTransaction ();
err = SKY_coin_Transactions_GetAt (handles, 5, tnxs_5);
assertEquals(err, SKY_OK);
count = new_GoUint32Ptr();
err = SKY_coin_Transaction_Size(tnxs_5, count);
count = new_GoUint32Ptr ();
err = SKY_coin_Transaction_Size (tnxs_5, count);
assertEquals(err, SKY_OK);
trunc += (GoUint32Ptr_value(count) - 2);
err = SKY_coin_Transactions_TruncateBytesTo(handles, trunc, tnxs2);
trunc += (GoUint32Ptr_value (count) - 2);
err = SKY_coin_Transactions_TruncateBytesTo (handles, trunc, tnxs2);
assertEquals(err, SKY_OK);
err = SKY_coin_Transactions_Length(tnxs2, len);
err = SKY_coin_Transactions_Length (tnxs2, len);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), 5);
err = SKY_coin_Transactions_Size(tnxs2, count);
assertEquals(GointPtr_value (len), 5);
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
SWIGTYPE_p_unsigned_int count_tnxs5 = new_GoUint32Ptr();
err = SKY_coin_Transaction_Size(tnxs_5, count_tnxs5);
SWIGTYPE_p_unsigned_int count_tnxs5 = new_GoUint32Ptr ();
err = SKY_coin_Transaction_Size (tnxs_5, count_tnxs5);
assertEquals(err, SKY_OK);
assertEquals((trunc - GoUint32Ptr_value(count_tnxs5) + 1),
GoUint32Ptr_value(count));
assertEquals((trunc - GoUint32Ptr_value (count_tnxs5) + 1), GoUint32Ptr_value (count));

// Moving to next level
trunc += 1;
err = SKY_coin_Transactions_TruncateBytesTo(handles, trunc, tnxs2);
err = SKY_coin_Transactions_TruncateBytesTo (handles, trunc, tnxs2);
assertEquals(err, SKY_OK);
err = SKY_coin_Transactions_Length(tnxs2, len);
err = SKY_coin_Transactions_Length (tnxs2, len);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), 6);
err = SKY_coin_Transactions_Size(tnxs2, count);
assertEquals(GointPtr_value (len), 6);
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), trunc);
assertEquals(GoUint32Ptr_value (count), trunc);

// Truncating to full available amt
SWIGTYPE_p_unsigned_int trunc1 = new_GoUint32Ptr();
err = SKY_coin_Transactions_Size(handles, trunc1);
SWIGTYPE_p_unsigned_int trunc1 = new_GoUint32Ptr ();
err = SKY_coin_Transactions_Size (handles, trunc1);
assertEquals(err, SKY_OK);
err = SKY_coin_Transactions_TruncateBytesTo(handles, GoUint32Ptr_value(trunc1),
tnxs2);
err = SKY_coin_Transactions_TruncateBytesTo (handles, GoUint32Ptr_value (trunc1), tnxs2);
assertEquals(err, SKY_OK);
err = SKY_coin_Transactions_Size(tnxs2, count);
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), GoUint32Ptr_value(trunc1));
assertEquals(GoUint32Ptr_value (count), GoUint32Ptr_value (trunc1));

// Truncating to 0
trunc = 0;
err = SKY_coin_Transactions_TruncateBytesTo(handles, 0, tnxs2);
err = SKY_coin_Transactions_TruncateBytesTo (handles, 0, tnxs2);
assertEquals(err, SKY_OK);
err = SKY_coin_Transactions_Length(tnxs2, len);
err = SKY_coin_Transactions_Length (tnxs2, len);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), 0);
err = SKY_coin_Transactions_Size(tnxs2, count);
assertEquals(GointPtr_value (len), 0);
err = SKY_coin_Transactions_Size (tnxs2, count);
assertEquals(err, SKY_OK);
assertEquals(GoUint32Ptr_value(count), trunc);
assertEquals(GoUint32Ptr_value (count), trunc);
}

class ux {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="skycoin.libjava.cipher_addressTest" time="3.601" tests="6" errors="0" skipped="0" failures="0">
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="skycoin.libjava.cipher_addressTest" time="3.61" tests="6" errors="0" skipped="0" failures="0">
<properties>
<property name="awt.toolkit" value="sun.awt.X11.XToolkit"/>
<property name="file.encoding.pkg" value="sun.io"/>
Expand All @@ -16,7 +16,7 @@
<property name="user.country" value="ES"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64"/>
<property name="sun.java.command" value="org.apache.maven.surefire.booter.ForkedBooter /home/maykel/go/src/github.com/skycoin/libjava-skycoin/target/surefire 2018-12-08T19-39-38_734-jvmRun1 surefire9105535938699069738tmp surefire_08816048143417404842tmp"/>
<property name="sun.java.command" value="org.apache.maven.surefire.booter.ForkedBooter /home/maykel/go/src/github.com/skycoin/libjava-skycoin/target/surefire 2018-12-08T22-00-09_038-jvmRun1 surefire8276479351130694237tmp surefire_02153064897970952075tmp"/>
<property name="surefire.test.class.path" value="/home/maykel/go/src/github.com/skycoin/libjava-skycoin/target/test-classes:/home/maykel/go/src/github.com/skycoin/libjava-skycoin/target/classes:/home/maykel/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/maykel/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/maykel"/>
Expand Down Expand Up @@ -56,10 +56,10 @@
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="52.0"/>
</properties>
<testcase name="TestDecodeBase58Address" classname="skycoin.libjava.cipher_addressTest" time="0.007"/>
<testcase name="TestAddressRoundtrip" classname="skycoin.libjava.cipher_addressTest" time="0.003"/>
<testcase name="TestAddressFromBytes" classname="skycoin.libjava.cipher_addressTest" time="0.004"/>
<testcase name="TestAddressVerify" classname="skycoin.libjava.cipher_addressTest" time="0.007"/>
<testcase name="TestAddressBulk" classname="skycoin.libjava.cipher_addressTest" time="3.575"/>
<testcase name="TestDecodeBase58Address" classname="skycoin.libjava.cipher_addressTest" time="0.005"/>
<testcase name="TestAddressRoundtrip" classname="skycoin.libjava.cipher_addressTest" time="0.004"/>
<testcase name="TestAddressFromBytes" classname="skycoin.libjava.cipher_addressTest" time="0.003"/>
<testcase name="TestAddressVerify" classname="skycoin.libjava.cipher_addressTest" time="0.006"/>
<testcase name="TestAddressBulk" classname="skycoin.libjava.cipher_addressTest" time="3.585"/>
<testcase name="TestAddressNull" classname="skycoin.libjava.cipher_addressTest" time="0.003"/>
</testsuite>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: skycoin.libjava.cipher_addressTest
-------------------------------------------------------------------------------
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.601 s - in skycoin.libjava.cipher_addressTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.61 s - in skycoin.libjava.cipher_addressTest

0 comments on commit bf4467d

Please sign in to comment.