Skip to content

Add model for getnodeaddresses - #191

Merged
tcharding merged 1 commit into
rust-bitcoin:masterfrom
jamillambert:0520-v18-network-model
May 21, 2025
Merged

tcharding merged 1 commit into
rust-bitcoin:masterfrom
jamillambert:0520-v18-network-model

Conversation

@jamillambert

Copy link
Copy Markdown
Collaborator

GetNodeAddresses returns an Address. Create a bitcoin::Address model for it and modify the test to use it.

Implement for v18 to v21. In v22 the return changes, label v22 to v28 as TODO.

GetNodeAddresses returns an Address.  Create a bitcoin::Address model
for it and modify the test to use it.

Implement for v18 to v21. In v22 the return changes, label v22 to v28 as
TODO.

@jamillambert jamillambert left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI fail looks unrelated

@tcharding

Copy link
Copy Markdown
Member

Yeah we have intermitent CI failures atm, in #147 it was suggested its to do with flaky downloads of Core.

@tcharding tcharding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 054862f

@tcharding
tcharding merged commit 9aca575 into rust-bitcoin:master May 21, 2025
@jamillambert

Copy link
Copy Markdown
Collaborator Author

Yeah we have intermitent CI failures atm, in #147 it was suggested its to do with flaky downloads of Core.

I've had them locally too running the tests.

@tcharding

Copy link
Copy Markdown
Member

Do you download locally or set BITCOIND_EXE?

@jamillambert

Copy link
Copy Markdown
Collaborator Author

Download locally. I'll try and dig a bit and see if I can find out more. But always hard with intermittent errors.

@tcharding

Copy link
Copy Markdown
Member

See the alias' in integration_test/README.md for running locally without downloading. Otherwise you'll download for every worktree and its too slow.

@tcharding

Copy link
Copy Markdown
Member

I'll try and dig a bit and see if I can find out more

I would guess we should just be adding repeat/timeout logic to the download code (in build.rs).

@tcharding

tcharding commented Aug 1, 2025 •

Copy link
Copy Markdown
Member

Ouch, in review I did not notice that the address returned is not a Bitcoin address but a 'node' address. I don't actually know what that means, is it IP address? Eitherway the model type is wrong and since the only reason it exists is because of the bitcoin::Address we don't need it at all.

EDIT: In getpeerinfo its IP:port but running two nodes locally with run-bitcoind.sh I still get an empty list for bt27 getnodeaddresses - maybe I'm misunderstanding something?

if let Some(addr) = json.0.first() {
let res: Result<mtype::GetNodeAddresses, _> = json.into_model();
let model = res.expect("GetNodeAddresses into model");
assert!(model.0.len() <= 2500);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing the list is empty 😂. It was an AI suggested sanity check that the list was smaller than the max allowed size.

Comment on lines +43 to 46
if let Some(addr) = model.0.first() {
assert!(addr.port > 0);
assert!(!addr.address.is_empty());
assert!(addr.time > 1231006505);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block will never be run because there is only one node started. We'd need to start a multi-node network to test this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #320 to follow this up. Adding a multi-node network did not work for me either.

@tcharding tcharding mentioned this pull request Aug 1, 2025
blaze-smith470pm added a commit to blaze-smith470pm/corepc that referenced this pull request Sep 26, 2025
054862f212ac5e8c7911fae7a0b64f565e3f9b7b Add model for getnodeaddresses (Jamil Lambert, PhD)

Pull request description:

  GetNodeAddresses returns an Address.  Create a bitcoin::Address model for it and modify the test to use it.

  Implement for v18 to v21. In v22 the return changes, label v22 to v28 as TODO.

ACKs for top commit:
  tcharding:
    ACK 054862f212ac5e8c7911fae7a0b64f565e3f9b7b

Tree-SHA512: 771e760ef8330748c93d7e20731a8e46a6d51e4c1b4b9087e6ac38f07477d8441c041b053dd14803879e40414ed5bdc1ede2512b69ac7d486f15dd039d3c0923
@jamillambert
jamillambert deleted the 0520-v18-network-model branch December 29, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants