-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added `chunk32` and `chunks32` to kwl32 - Added `PartialEq` to `Bytes` and `Word` - Added `remove` and `__remove` to `View` - Added `len` wrapper and `partialEq` to `Calldata` - Added tests to cover base types
- Loading branch information
Showing
12 changed files
with
363 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `kawala` crate."><title>kawala - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-492a78a4a87dcc01.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="kawala" data-themes="" data-resource-suffix="" data-rustdoc-version="1.82.0-nightly (a7399ba69 2024-08-31)" data-channel="nightly" data-search-js="search-a99f1315e7cc5121.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-921df33f47b8780c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-3b12f09e550e0385.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../kawala/index.html">kawala</a><span class="version">0.1.3</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">kawala</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/kawala/lib.rs.html#12-545">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="bai/index.html" title="mod kawala::bai">bai</a></div></li><li><div class="item-name"><a class="mod" href="kwl32/index.html" title="mod kawala::kwl32">kwl32</a></div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Calldata.html" title="struct kawala::Calldata">Calldata</a></div></li><li><div class="item-name"><a class="struct" href="struct.Signature.html" title="struct kawala::Signature">Signature</a></div></li><li><div class="item-name"><a class="struct" href="struct.View.html" title="struct kawala::View">View</a></div></li><li><div class="item-name"><a class="struct" href="struct.Word.html" title="struct kawala::Word">Word</a></div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Bytes.html" title="enum kawala::Bytes">Bytes</a></div></li><li><div class="item-name"><a class="enum" href="enum.WithSig.html" title="enum kawala::WithSig">WithSig</a></div></li></ul></section></div></main></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//--------------------------------------- CALLDATA TYPE -----------------------------------------// | ||
// ----------------------------------------------------------------------------------------------// | ||
#[cfg(test)] | ||
mod calldata { | ||
use kawala::{ Calldata }; | ||
// ----------------------------------- CREATION AND ACCESS --------------------------------------// | ||
|
||
#[test] | ||
fn call_creation_and_access_from_bytes() { | ||
let call = Calldata::from_bytes(&[0x01,0x02,0x03,0x04]); | ||
assert_eq!(call.bytes(), [0x01,0x02,0x03,0x04]); | ||
assert_eq!(call.len(), 4); | ||
assert_eq!(call.bytes()[0], 1); | ||
} | ||
|
||
#[test] | ||
fn call_creation_and_access_from_hex() { | ||
let call = Calldata::from_hex("01020304"); | ||
assert_eq!(call.bytes(), [0x01,0x02,0x03,0x04]); | ||
assert_eq!(call.len(), 4); | ||
assert_eq!(call.bytes()[0], 1); | ||
} | ||
|
||
// ---------------------------------------- LEN & HEX -------------------------------------------// | ||
|
||
#[test] | ||
fn hex_conversion() { | ||
let call = Calldata::from_bytes(&[0xFF; 32]); | ||
assert_eq!(call.hex(), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); | ||
} | ||
|
||
#[test] | ||
fn len_wrapper() { | ||
let call = Calldata::from_bytes(&[1, 2, 3, 4]); | ||
assert_eq!(call.len(), 4); | ||
} | ||
|
||
// --------------------------------------- COMPARISONS ------------------------------------------// | ||
|
||
#[test] | ||
fn call_equality_match() { | ||
let a = Calldata::from_bytes(&[0u8;4]); | ||
let b = Calldata::from_bytes(&[0u8;4]); | ||
assert_eq!(a, b); | ||
} | ||
|
||
#[test] | ||
fn call_equality_no_match() { | ||
let a = Calldata::from_bytes(&[0u8;4]); | ||
let b = Calldata::from_bytes(&[1u8;4]); | ||
assert_ne!(a, b); | ||
} | ||
|
||
// --------------------------------------- GENERAL ------------------------------------------// | ||
|
||
#[test] | ||
fn call() -> () { | ||
let call = Calldata::from_bytes(&[0u8;32]); | ||
assert_eq!(call.len(), 32); | ||
let call = Calldata::from_hex(&"0".repeat(64)); | ||
assert_eq!(call.len(), 32); | ||
} | ||
|
||
#[test] | ||
fn more_than_32() { | ||
let call = Calldata::from_bytes(&[0u8;64]); | ||
assert_eq!(call.len(), 64); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.