derohe-miniblock-mod/proof/proof_test.go
2021-11-08 16:39:17 +00:00

53 lines
6.2 KiB
Go

// Copyright 2017-2018 DERO Project. All rights reserved.
// Use of this source code in any form is governed by RESEARCH license.
// license can be found in the LICENSE file.
// GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
//
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proof
import "testing"
// this function will prove detect and decode output amount for the tx
func Test_Prove(t *testing.T) {
var proof = "deroproof1qy24csrhmq90tdh7cr4njrykph9ymuqqkrly42s22n3eh3xdzkklvqdzvfyyskpqjrh5tp9gdasplscd4yegt9zctlt6e02cj8ftpa967v6md5v2ctyky4j4rgqqrdkevc4nyr"
var ring_address = [][]string{{
"deto1qyre7td6x9r88y4cavdgpv6k7lvx6j39lfsx420hpvh3ydpcrtxrxqg8v8e3z",
"deto1qy35yu06tu4uyakeqxen6nh2g3ltgwwstrk5unh573hwq6w7sz3pcqqxfmhzz",
"deto1qywaj56ew38wjrpsq4wwrjj6nlsngu8ytluadhekyhr6s7fh2dmjuqg75x2nm",
"deto1qyx7qyvrtrhvaszeej487k2g689fav7h38ay37fja9qf40ycgl0m2qg8ap2y9",
}}
var tx_hex = "01000003030100000000000000000000000000000000000000000000000000000000000000000000c5d59d096efe0624f776e5e81bfa6d38f19aeefff57d999fb76883392ee4d6a55cb04d7f74c6ddf3a5ec55bcb848b8e46283468af1513ffb581daaa8b7879abe5be5963c65b4918818954d2397be09a7b1c10fce1692c7fa32bb2d06f2cc2ded949bc18335ed32fd92ef703d9f55282e50fffe18103440647577b31297f891144e970e2a6b7e034fd926dc380d304b0b6e02030012f8012f6cddc1850a6fb2766d585bcf285a086b78f7bfc4f25e0cc40aac8cfa00a12fda5e3799e9246044ead00ff1f19fca461d7e255a7af87f2909bbad036196018e7cea50686107e6c625d20003bd194ae43426600e745c0d253a2d679dd93fb79a7f3c4b071a62d5f84e6232012f920ed92f2ddb2efbacb27e4bad256233ba0227d20b1f6753448b80787c467d000c9d77a2a93e516fc8d445b92fb87138616ccab9425a8b03dba1b452243c82f601bf091517d58e1620cf31b1b44ce68ea4cd2a0eb89342cd400ba09a015a8cc2693044e7b42d37879ff60609bb3bf65587bfd2811bc052ddbb164397164091fe8201132ca6567a44b63a8ab79e6f6bb6b783a23cccefc60b19caeae407a1bde6ba29012599faeed73f71639cd8cad6ae349b88d327d1b28d5dee6fbceb31e06238804e01209a5bbea37113654461558a84dac6c1b9d908998ab7df7745611c45bbc69073002787aa2f8fbe2c96adec3b22dcbc3288f9a19813ee26389a9dc7112e634d854a001c786445883d4a9ff64ab67ac238ec805601909f029cff18a2bd9dd43d5dd08f011096f90ec4528085dd60ce7b9b40e7a13c4c6b682fb37b0f65f3625edc5a6fd90011ad2d65c97b025068f0220bb49d6e8473e2927b045fcac360e7d7925e51592f000fbea3321a3e61da67e82e8fb85fa278dbb35ae96da7195c0d9a5207915b9d02002a7a2eda627caa376051379d7e160a147b2ff20d7956741df1bd3e8bb702a7160016e5b5ea07306beff5ebee45c866298be2efefd277b883f8e717a8aad0794a5e0018a8e9fc2af18cf23fe26fdd84bc501f52a64f67a1b8839b61453afc681e02f3012eff2daca0d8857b529625cecffab7816f364636e9ad9ea4949286d76a5528740006a55b12300cbc5d279e3c6278b48cd45b9fa4ebf8f32301ab0e34c39bcb01f3001c3221b95842774c6d4782cf7bf0bdbee47a390ee507593aeb060fc22b562118002149ca7f5682d4383affa31f9b5fe91663671fbf6e0c86a2681150de8e371d8f011ec67465b20d6516a476258801ed75898a4ac21b1c66f661ccc78a4ee57f94b7001d3599550f322a85a28763dbd6aa440ef1c484602535aa120490e3c403c10567011d944754272ed2637fa8458d825dc4318ef4f4691ec5426620542f77d341655f01089816eb3f43825508cfa31a89a93c626911dfef0d1aa1365300bb90e3bdefee0115d135a01a05c0c13c989c10227e354ccdba6bba820fd6ba15aad825a5088b2c00000000000000000000000000000000000000000000000000000000000000000025e9e7b994c9e4f495ae4e208cacd44078efed3e3b96c455af8966cedbadac8303aff8687c6e5eee2e5587dd01d830b8f5b314b1dd7a2662bfbbe91b547d1679160a0f59543e6877088b138d1c02b7c626f2a42f3bb50d38d4369805d4674962255f8a0cbf09d3f14c3c1f3b386a414cd18cd56bdac89fc35896a7db045044c41893024f3cec7bd74c99f2ae029c56750b598b4958d17666ee3cd06a36dc3b000013e11d8b0b17205d32b47b097a11e616dc352a1f4223da945f7c741de0834a0b01169422af606adef80e00559470b4e71c84c03da141bf6bb619feeb91d55bcae40481e14e67c0ae1489f7f01843845bf26482e1f2d72fa4bbde1386a4e74fd5a3191edd62e81be2bc1b47ca8711e98199334b27a0bdd3ea03f041bc342a3ea6b32c92c5b5d2b7c3196335fdf58fe5293ea21b465d081bc9fb10e55bce480bd07019ee788c080839f5da2dc3a43774de76b27c9c6391b91255d89731cd03ee546400d64e8b28eb1cbcaaadb8fa75ca0cee438a9ef8f32465ab148b0354973dc1c70e1b0a5629156b64fb3fb213c9971cd35d32b1e1c4d5bf8a9a14d8da092f0a961cbacca34c22b4e4ec35f68d0827b538b2604c9f9566fb4a478beb1a77de07c2104ba1f6c184586263473a1ef8081bc0c126376f72589d86bfbbb57dd3897ff616a81723f93c52199594327d775296a175d29691dc715820a6e60b63417a1f37010da1c0b870d0aeb44845f8a190021fd15e5b02c8c23e2c662e90b69e490b597c0015e0c97936ee5fd8f76e0b8c531eb97be6f44020836eeb09f7651fdfe395db3b0000f20bab4dc90e1b58c794e84e8322c692116d60b44480182a5d02f1ad6e2089012febbc7375180949d38774ebc4a29a8a66b1ce117d7886ec4e9e69d90463a387011c6bc2f8977fd7da0aff7e76a79e273ea82773ae0a028cdaea53936b47f050d5010512cd6f442f22cb5456643df0924821e3943a9f156f6bfc55ff47ee7d24b12b000d638109aa8e4321d11945296fe1d0a3ed590d896ae710e6372f8471ae25d10e002296b6e4f9e598031f317e95184f030e8906533974b40013fb82aa3cf2b14edd01147cf372588499147eb6954aeb27aed1a3893b229ce94801fce5f295207123a2001642efb349312fe6b67eb52508968ea17e0b98a94aa5b2ad4f1424c90338871d010c782f8548719218fda4ea9bf7967cf2683f72a15cd1b1d3250cc842c54756ff012b76046c131e90c0b177cbd859c9236cfc62a2e1c090d5cac38a924a5dcfa1170007720f6d0254dd7f7f9976f58e484da2da0aea1dad7e4dd4c3724363717f1ef400"
mainnet := true
receivers, amounts, payload_raw, payload_decoded, err := Prove(proof, tx_hex, ring_address, mainnet)
if err != nil {
t.Fatalf("Proving transaction failed err %s", err)
}
_ = payload_raw
_ = payload_decoded
if len(receivers) != len(amounts) && len(amounts) != 1 {
t.Fatalf("Proving transaction failed expected 1,1 actual %d,%d", len(receivers), len(amounts))
}
if amounts[0] != 112345 {
t.Fatalf("Proving transaction failed expected 112345, actual %d", amounts[0])
}
}