apoelstra / rust-jsonrpc

Rust JSONRPC library
Creative Commons Zero v1.0 Universal
158 stars 62 forks source link

minreq http is not working? #113

Closed RCasatta closed 8 months ago

RCasatta commented 8 months ago

From the integration_test subdir after setting RPC_COOKIE and RPC_URL

integration_test(master)$ cargo run

 Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `/home/casatta/git/rust-jsonrpc/target/debug/integration_test`
Running test_get_network_info...
panicked at integration_test/src/main.rs:153:38:
called `Result::unwrap()` on an `Err` value: Transport(Minreq(IoError(Custom { kind: Other, error: "was redirected to an absolute url with an invalid protocol" })))
   0: integration_test::main::{{closure}}
             at src/main.rs:112:18
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
      std::panicking::rust_panic_with_hook
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
   4: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   5: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   6: core::result::unwrap_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
   7: core::result::Result<T,E>::unwrap
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23
   8: integration_test::test_get_network_info
             at src/main.rs:153:13
   9: integration_test::main::{{closure}}
             at src/main.rs:92:13
  10: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  11: __rust_try
  12: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  13: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  14: integration_test::main
             at src/main.rs:116:5
  15: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  16: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  17: std::rt::lang_start::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  18: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  19: std::rt::lang_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  20: main
  21: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  22: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:392:3
  23: _start
apoelstra commented 8 months ago

On my end I get this failure if I try to run the integration tests without modification, but if I comment out two of the tests and run them individually, I get errors related to a hash mismatch.

So I think the minreq stuff is a red herring -- what's actually happening is that we're getting some sort of hash mismatch (which itself is a bug) and then our crazy integration test shutdown logic is confusing minreq.

Basically we should rewrite the integration test harness.

apoelstra commented 8 months ago

@RCasatta when you run ./run.sh do the tests pass?

I think the issue is that you're connecting to a mainnet node, so the blockhashes are real blockhashes instead of integration-test ones, so our code asserts on this, then shuts down the HTTP client, then a parallel test panics because the HTTP client is shut down.

Personally I think we should just rip out the paralellization logic and the lazy statics etc etc and just run the tests in series.

RCasatta commented 8 months ago

@RCasatta when you run ./run.sh do the tests pass?

Yes, and also your analyses is correct (I didn't notice run.sh so I used a local instance).

I am hitting the same error downstream and I thought to have that replicated but here seem another reason

RCasatta commented 8 months ago

FYI, the error I had in migrating from simplehttp to minreq was due to the fact that minreq requires the protocol to be explicit in the url while simplehttp defaults to http.