Permalink
Browse files

More code cleanup for monotone cart.

  • Loading branch information...
1 parent e8d7981 commit 82b08d12a097a85562914db726fa4b19c0dbbba8 @neilconway neilconway committed Sep 22, 2012
Showing with 11 additions and 13 deletions.
  1. +7 −7 cart/monotone_cart.rb
  2. +4 −6 test/tc_monotone_cart.rb
View
@@ -6,11 +6,11 @@
module MonotoneCartProtocol
state do
channel :action_msg,
- [:@server, :client, :session, :op_id] => [:item, :cnt]
+ [:@server, :session, :op_id] => [:item, :cnt]
channel :checkout_msg,
- [:@server, :client, :session, :op_id] => [:lbound]
+ [:@server, :session, :op_id] => [:lbound, :addr]
channel :response_msg,
- [:@client, :server, :session] => [:items]
+ [:@client, :session] => [:items]
end
end
@@ -26,15 +26,15 @@ module MonotoneReplica
end
sessions <= checkout_msg do |m|
- c = CartLattice.new({m.op_id => [CHECKOUT_OP, m.lbound, m.client]})
+ c = CartLattice.new({m.op_id => [CHECKOUT_OP, m.lbound, m.addr]})
{ m.session => c }
end
# XXX: Note that we will send an unbounded number of response messages for
# each complete cart.
response_msg <~ sessions.to_collection do |session, cart|
cart.is_complete.when_true {
- [cart.checkout_addr, ip_port, session, cart.summary]
+ [cart.checkout_addr, session, cart.summary]
}
end
end
@@ -51,10 +51,10 @@ module MonotoneClient
bloom do
action_msg <~ (do_action * serv).pairs do |a,s|
- [s.addr, ip_port, a.session, a.op_id, a.item, a.cnt]
+ [s.addr, a.session, a.op_id, a.item, a.cnt]
end
checkout_msg <~ (do_checkout * serv).pairs do |c,s|
- [s.addr, ip_port, c.session, c.op_id, c.lbound]
+ [s.addr, c.session, c.op_id, c.lbound, ip_port]
end
end
end
@@ -153,8 +153,7 @@ def test_monotone_simple
c.sync_callback(:do_action, [[10, 3, 'beer', -1]], :response_msg)
c.sync_do {
- assert_equal([[c.ip_port, s.ip_port, 10,
- [['vodka', 4]]]], c.response_log.to_a)
+ assert_equal([[c.ip_port, 10, [['vodka', 4]]]], c.response_log.to_a)
}
[c, s].each {|n| n.stop}
@@ -173,17 +172,16 @@ def test_monotone_multi_session
c.sync_callback(:do_checkout, [[11, 9, 8]], :response_msg)
c.sync_do {
- assert_equal([[c.ip_port, s.ip_port, 11,
- [['coffee', 2]]]], c.response_log.to_a)
+ assert_equal([[c.ip_port, 11, [['coffee', 2]]]], c.response_log.to_a)
}
c.sync_do {
c.do_checkout <+ [[12, 3, 1]]
}
c.sync_callback(:do_action, [[12, 1, 'rye', 1]], :response_msg)
c.sync_do {
- assert_equal([[c.ip_port, s.ip_port, 11, [['coffee', 2]]],
- [c.ip_port, s.ip_port, 12, [['gin', 3], ['rye', 1]]]],
+ assert_equal([[c.ip_port, 11, [['coffee', 2]]],
+ [c.ip_port, 12, [['gin', 3], ['rye', 1]]]],
c.response_log.to_a.sort)
}

0 comments on commit 82b08d1

Please sign in to comment.