|
1 | 1 | package eu.bittrade.libs.steemj.plugins.witness.model.operations; |
2 | 2 |
|
3 | | -import eu.bittrade.libs.steemj.BaseTransactionBroadcastIT; |
| 3 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 4 | +import static org.hamcrest.Matchers.equalTo; |
4 | 5 |
|
5 | | -public class EnableContentEditingOperationIT extends BaseTransactionBroadcastIT { |
| 6 | +import java.util.ArrayList; |
| 7 | + |
| 8 | +import org.junit.BeforeClass; |
| 9 | +import org.junit.Test; |
| 10 | +import org.junit.experimental.categories.Category; |
| 11 | + |
| 12 | +import eu.bittrade.libs.steemj.BaseTransactionVerificationIT; |
| 13 | +import eu.bittrade.libs.steemj.IntegrationTest; |
| 14 | +import eu.bittrade.libs.steemj.base.models.AccountName; |
| 15 | +import eu.bittrade.libs.steemj.base.models.SignedTransaction; |
| 16 | +import eu.bittrade.libs.steemj.base.models.TimePointSec; |
| 17 | +import eu.bittrade.libs.steemj.base.models.operations.CustomJsonOperation; |
| 18 | +import eu.bittrade.libs.steemj.base.models.operations.Operation; |
| 19 | + |
| 20 | +/** |
| 21 | + * Verify the functionality of the {@link EnableContentEditingOperation} under |
| 22 | + * the use of real api calls. |
| 23 | + * |
| 24 | + * @author <a href="http://steemit.com/@dez1337">dez1337</a> |
| 25 | + */ |
| 26 | + |
| 27 | +public class EnableContentEditingOperationIT extends BaseTransactionVerificationIT { |
| 28 | + private static final String EXPECTED_TRANSACTION_HEX = "f68585abf4dcf33ed759011200010764657a31333337077769746e6573" |
| 29 | + + "735b5b22456e61626c65436f6e74656e7445646974696e674f7065726174696f6e222c7b226163636f756e74223a2264657a313" |
| 30 | + + "33337222c2272656c6f636b5f74696d65223a22323031372d31312d32375430383a32393a3237227d5d00011c47186762f9171a" |
| 31 | + + "8df9af273c09bcfcc7947c9325285ec688a4144f88c763940b30e6df6ea688d7b16341cd6b03f56f6d5524521172418ffda96aa" |
| 32 | + + "cfff0492dc6"; |
| 33 | + private static final String EXPECTED_TRANSACTION_HEX_TESTNET = "f68585abf4dc71fce558041200010764657a3133333706666f" |
| 34 | + + "6c6c6f77465b22666f6c6c6f77222c7b22666f6c6c6f776572223a2264657a31333337222c22666f6c6c6f77696e67223a22737" |
| 35 | + + "465656d6a222c2277686174223a5b22626c6f67225d7d5d1200010764657a3133333706666f6c6c6f77425b22666f6c6c6f7722" |
| 36 | + + "2c7b22666f6c6c6f776572223a2264657a31333337222c22666f6c6c6f77696e67223a22737465656d6a222c2277686174223a5" |
| 37 | + + "b22225d7d5d1200010764657a3133333706666f6c6c6f77485b22666f6c6c6f77222c7b22666f6c6c6f776572223a2264657a31" |
| 38 | + + "333337222c22666f6c6c6f77696e67223a22737465656d6a222c2277686174223a5b2269676e6f7265225d7d5d1200010764657" |
| 39 | + + "a31333337067265626c6f67755b227265626c6f67222c7b226163636f756e74223a2264657a31333337222c22617574686f7222" |
| 40 | + + "3a22737465656d6a222c227065726d6c696e6b223a22737465656d6a2d76302d342d302d666561747572652d707265766965772" |
| 41 | + + "d73696d706c69666965642d7472616e73616374696f6e73227d5d00011c0e678ad549add722ad72c6f03887b4fceb2fbe4f79de" |
| 42 | + + "9052ce505f3784ceb02c76e49f4f6f5ab7f2bc5a108fa11d51119a5fc21884063a2da6a546cae6866191"; |
| 43 | + |
| 44 | + /** |
| 45 | + * <b>Attention:</b> This test class requires a valid active key of the used |
| 46 | + * "owner". If no active key is provided or the active key is not valid an |
| 47 | + * Exception will be thrown. The active key is passed as a -D parameter |
| 48 | + * during test execution. |
| 49 | + * |
| 50 | + * @throws Exception |
| 51 | + * If something went wrong. |
| 52 | + */ |
| 53 | + @BeforeClass() |
| 54 | + public static void prepareTestClass() throws Exception { |
| 55 | + setupIntegrationTestEnvironmentForTransactionVerificationTests(HTTP_MODE_IDENTIFIER, |
| 56 | + TESTNET_ENDPOINT_IDENTIFIER); |
| 57 | + |
| 58 | + ArrayList<AccountName> requiredPostingAuths = new ArrayList<>(); |
| 59 | + requiredPostingAuths.add(new AccountName("dez1337")); |
| 60 | + |
| 61 | + // Steem does not allow to combine operations that require a posting key |
| 62 | + // with operations that require a higher key, so set the active |
| 63 | + // authorities to null. |
| 64 | + ArrayList<AccountName> requiredActiveAuths = null; |
| 65 | + |
| 66 | + String id = "witness"; |
| 67 | + |
| 68 | + EnableContentEditingOperation enableContentEditingOperation = new EnableContentEditingOperation( |
| 69 | + new AccountName("dez1337"), new TimePointSec("2017-11-27T08:29:27UTC")); |
| 70 | + |
| 71 | + CustomJsonOperation customJsonEnableContentEditingOperationn = new CustomJsonOperation(requiredActiveAuths, |
| 72 | + requiredPostingAuths, id, enableContentEditingOperation.toJson()); |
| 73 | + |
| 74 | + ArrayList<Operation> operations = new ArrayList<>(); |
| 75 | + operations.add(customJsonEnableContentEditingOperationn); |
| 76 | + |
| 77 | + // If the default expiration date for all integration tests |
| 78 | + // (2016-04-06T08:29:27UTC) is used, the transaction can't be verified. |
| 79 | + // As a workaround new date is set that is not that far in the past. |
| 80 | + signedTransaction = new SignedTransaction(REF_BLOCK_NUM, REF_BLOCK_PREFIX, |
| 81 | + new TimePointSec("2017-10-06T08:29:27UTC"), operations, null); |
| 82 | + signedTransaction.sign(); |
| 83 | + } |
| 84 | + |
| 85 | + @Category({ IntegrationTest.class }) |
| 86 | + @Test |
| 87 | + public void verifyTransaction() throws Exception { |
| 88 | + assertThat(steemJ.verifyAuthority(signedTransaction), equalTo(true)); |
| 89 | + } |
| 90 | + |
| 91 | + @Category({ IntegrationTest.class }) |
| 92 | + @Test |
| 93 | + public void getTransactionHex() throws Exception { |
| 94 | + if (TEST_ENDPOINT.equals(TESTNET_ENDPOINT_IDENTIFIER)) { |
| 95 | + assertThat(steemJ.getTransactionHex(signedTransaction), equalTo(EXPECTED_TRANSACTION_HEX_TESTNET)); |
| 96 | + } else { |
| 97 | + assertThat(steemJ.getTransactionHex(signedTransaction), equalTo(EXPECTED_TRANSACTION_HEX)); |
| 98 | + } |
| 99 | + } |
6 | 100 |
|
7 | 101 | } |
0 commit comments