Skip to content

How can i write test case for function fetch_github_info in Offchain worker example #459

@CocDap

Description

@CocDap

Hello, I try to write a test case for checking function fetch_github_info in offchain worker. But it failed.

#[test]                                                                                                              
fn fetch_submit_info_works() {                                                                                       
      let (mut t, _, _) = ExternalityBuilder::build();                                                                 
      t.execute_with(|| {                                                                                              
            System::set_block_number(4);
            assert_ok!(OcwDemo::fetch_github_info())
});
}

It catch Error in line 405 that Response doesnt response from API in function fn fetch_from_remote()
image
image

But when I check in Polkadot.js.org it works and has fetched data from API
Can you have any idea to fix this?
I updated, but it failed because data stores in offchain worker has None
image

Thank you very much

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions