From 84f001b4cf2573e254a98545465f4985e450359d Mon Sep 17 00:00:00 2001 From: Ayush Agrawal Date: Fri, 17 Apr 2026 18:38:27 -0400 Subject: [PATCH 1/2] test: document Luerl table reference semantics for ao.unset egression test for the patch@1.0 sentinel pattern. Demonstrates that passing a full table into an outbox-like container and then setting a key to nil erases it from both sides. Hence, there is an erratic behaviour in the patched state. --- src/dev_lua.erl | 14 ++++++++++++++ test/test.lua | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/dev_lua.erl b/src/dev_lua.erl index 0e0483251..dc38ebca4 100644 --- a/src/dev_lua.erl +++ b/src/dev_lua.erl @@ -517,6 +517,20 @@ simple_invocation_test() -> }, ?assertEqual(2, hb_ao:get(<<"assoctable/b">>, Base, #{})). +ao_unset_reference_bug_test() -> + {ok, Script} = file:read_file("test/test.lua"), + Base = #{ + <<"device">> => <<"lua@5.3a">>, + <<"module">> => #{ + <<"content-type">> => <<"application/lua">>, + <<"body">> => Script + }, + <<"parameters">> => [] + }, + {ok, Res} = hb_ao:resolve(Base, <<"ao_unset_reference_bug">>, #{}), + ?assertEqual(not_found, hb_ao:get(<<"shared/wallet1">>, Res, #{})), + ?assertEqual(<<"__ao-unset__">>, hb_ao:get(<<"targeted/wallet1">>, Res, #{})). + post_invocation_message_validation_test() -> {ok, Script} = file:read_file("test/test.lua"), Opts = #{ priv_wallet => hb:wallet() }, diff --git a/test/test.lua b/test/test.lua index cae364585..dd2719572 100644 --- a/test/test.lua +++ b/test/test.lua @@ -160,4 +160,19 @@ function inc(base, req, opts) base.count = base.count or 0 base.count = base.count + 1 return base +end + +function ao_unset_reference_bug(base, req, opts) + local Routes = { ["wallet1"] = "__ao-unset__" } + local shared = { routes = Routes } + Routes["wallet1"] = nil + + local targeted = { routes = {["wallet1"] = "__ao-unset__"} } + + local outbox = { + shared = shared.routes, + targeted = targeted.routes + } + + return outbox end \ No newline at end of file From c01f7d5bd4899ebdc5ac0f86688d60a88995321e Mon Sep 17 00:00:00 2001 From: Ayush Agrawal Date: Fri, 17 Apr 2026 18:38:27 -0400 Subject: [PATCH 2/2] test: document Luerl table reference semantics for ao.unset egression test for the patch@1.0 sentinel pattern. Demonstrates that passing a full table into an outbox-like container and then setting a key to nil erases it from both sides. Hence, there is an erratic behaviour in the patched state. Co-authored-by: Jack Frain --- src/dev_lua.erl | 14 ++++++++++++++ test/test.lua | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/dev_lua.erl b/src/dev_lua.erl index 0e0483251..dc38ebca4 100644 --- a/src/dev_lua.erl +++ b/src/dev_lua.erl @@ -517,6 +517,20 @@ simple_invocation_test() -> }, ?assertEqual(2, hb_ao:get(<<"assoctable/b">>, Base, #{})). +ao_unset_reference_bug_test() -> + {ok, Script} = file:read_file("test/test.lua"), + Base = #{ + <<"device">> => <<"lua@5.3a">>, + <<"module">> => #{ + <<"content-type">> => <<"application/lua">>, + <<"body">> => Script + }, + <<"parameters">> => [] + }, + {ok, Res} = hb_ao:resolve(Base, <<"ao_unset_reference_bug">>, #{}), + ?assertEqual(not_found, hb_ao:get(<<"shared/wallet1">>, Res, #{})), + ?assertEqual(<<"__ao-unset__">>, hb_ao:get(<<"targeted/wallet1">>, Res, #{})). + post_invocation_message_validation_test() -> {ok, Script} = file:read_file("test/test.lua"), Opts = #{ priv_wallet => hb:wallet() }, diff --git a/test/test.lua b/test/test.lua index cae364585..dd2719572 100644 --- a/test/test.lua +++ b/test/test.lua @@ -160,4 +160,19 @@ function inc(base, req, opts) base.count = base.count or 0 base.count = base.count + 1 return base +end + +function ao_unset_reference_bug(base, req, opts) + local Routes = { ["wallet1"] = "__ao-unset__" } + local shared = { routes = Routes } + Routes["wallet1"] = nil + + local targeted = { routes = {["wallet1"] = "__ao-unset__"} } + + local outbox = { + shared = shared.routes, + targeted = targeted.routes + } + + return outbox end \ No newline at end of file