|
| 1 | +// |
| 2 | +// MIT License |
| 3 | +// |
| 4 | +// Copyright (c) 2017-2018 Thibault Martinez and Simon Ninon |
| 5 | +// |
| 6 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +// of this software and associated documentation files (the "Software"), to deal |
| 8 | +// in the Software without restriction, including without limitation the rights |
| 9 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +// copies of the Software, and to permit persons to whom the Software is |
| 11 | +// furnished to do so, subject to the following conditions: |
| 12 | +// |
| 13 | +// The above copyright notice and this permission notice shall be included in all |
| 14 | +// copies or substantial portions of the Software. |
| 15 | +// |
| 16 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +// SOFTWARE. |
| 23 | +// |
| 24 | +// |
| 25 | + |
| 26 | +#include <gtest/gtest.h> |
| 27 | + |
| 28 | +#include <iota/api/extended.hpp> |
| 29 | +#include <iota/crypto/checksum.hpp> |
| 30 | +#include <iota/errors/bad_request.hpp> |
| 31 | +#include <iota/errors/illegal_state.hpp> |
| 32 | +#include <test/utils/configuration.hpp> |
| 33 | +#include <test/utils/constants.hpp> |
| 34 | +#include <test/utils/expect_exception.hpp> |
| 35 | + |
| 36 | +TEST(Extended, ReplayBundle) { |
| 37 | + IOTA::API::Extended api(get_proxy_host(), get_proxy_port(), true, 380); |
| 38 | + |
| 39 | + auto res = api.replayBundle(BUNDLE_3_TRX_1_HASH, 27, 14); |
| 40 | + |
| 41 | + ASSERT_EQ(res.getSuccessfully().size(), 4UL); |
| 42 | + ASSERT_EQ(res.getSuccessfully(), std::vector<bool>({ true, true, true, true })); |
| 43 | +} |
| 44 | + |
| 45 | +TEST(Extended, ReplayBundleNonTailTransaction) { |
| 46 | + IOTA::API::Extended api(get_proxy_host(), get_proxy_port()); |
| 47 | + |
| 48 | + EXPECT_EXCEPTION(api.replayBundle(BUNDLE_3_TRX_4_HASH, 27, 14), IOTA::Errors::IllegalState, |
| 49 | + "Invalid tail transaction supplied."); |
| 50 | +} |
| 51 | + |
| 52 | +TEST(Extended, ReplayBundleBundleHash) { |
| 53 | + IOTA::API::Extended api(get_proxy_host(), get_proxy_port()); |
| 54 | + |
| 55 | + EXPECT_EXCEPTION(api.replayBundle(BUNDLE_3_HASH, 27, 14), IOTA::Errors::IllegalState, |
| 56 | + "Invalid transaction supplied."); |
| 57 | +} |
| 58 | + |
| 59 | +TEST(Extended, ReplayBundleInvalidHash) { |
| 60 | + IOTA::API::Extended api(get_proxy_host(), get_proxy_port()); |
| 61 | + |
| 62 | + EXPECT_EXCEPTION(api.replayBundle("hello", 27, 14), IOTA::Errors::IllegalState, |
| 63 | + "Invalid transaction supplied."); |
| 64 | +} |
0 commit comments